ID2D1DeviceContext::GetTarget method (d2d1_1.h)
Gets the target currently associated with the device context.
Syntax
void GetTarget(
[out, optional] ID2D1Image **image
);
Parameters
[out, optional] image
Type: ID2D1Image**
When this method returns, contains the address of a pointer to the target currently associated with the device context.
Return value
None
Remarks
If a target is not associated with the device context, target will contain NULL when the methods returns.
If the currently selected target is a bitmap rather than a command list, the application can gain access to the initial bitmaps created by using one of the following methods:
- CreateHwndRenderTarget
- CreateDxgiSurfaceRenderTarget
- CreateWicBitmapRenderTarget
- CreateDCRenderTarget
- CreateCompatibleRenderTarget
CreateDxgiSurfaceRenderTarget will create a bitmap that is usable as a bitmap source if the DXGI surface is bindable as a shader resource view.
CreateCompatibleRenderTarget will always create bitmaps that are usable as a bitmap source.
ID2D1RenderTarget::BeginDraw will copy from the HDC to the original bitmap associated with it. ID2D1RenderTarget::EndDraw will copy from the original bitmap to the HDC.
IWICBitmap objects will be locked in the following circumstances:
- BeginDraw has been called and the currently selected target bitmap is a WIC bitmap.
- A WIC bitmap is set as the target of a device context after BeginDraw has been called and before EndDraw has been called.
- Any of the ID2D1Bitmap::Copy* methods are called with a WIC bitmap as either the source or destination.
- EndDraw is called and the currently selected target bitmap is a WIC bitmap.
- A WIC bitmap is removed as the target of a device context between the calls to BeginDraw and EndDraw.
- Any of the ID2D1Bitmap::Copy* methods are called with a WIC bitmap as either the source or destination.
Calling QueryInterface for ID2D1GdiInteropRenderTarget will always succeed. ID2D1GdiInteropRenderTarget::GetDC will return a device context corresponding to the currently bound target bitmap. GetDC will fail if the target bitmap was not created with the GDI_COMPATIBLE flag set.
ID2D1HwndRenderTarget::Resize will return DXGI_ERROR_INVALID_CALL if there are any outstanding references to the original target bitmap associated with the render target.
Although the target can be a command list, it cannot be any other type of image. It cannot be the output image of an effect.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 8 and Platform Update for Windows 7 [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2012 and Platform Update for Windows Server 2008 R2 [desktop apps | UWP apps] |
Target Platform | Windows |
Header | d2d1_1.h |
DLL | D2d1.dll |