ID2D1DeviceContext::CreateBitmapFromDxgiSurface(IDXGISurface*,constD2D1_BITMAP_PROPERTIES1&,ID2D1Bitmap1**) method (d2d1_1.h)

Creates a bitmap from a DXGI surface that can be set as a target surface or have additional color context information specified.

Syntax

HRESULT CreateBitmapFromDxgiSurface(
  [in]           IDXGISurface                    *surface,
  [in, optional] const D2D1_BITMAP_PROPERTIES1 & bitmapProperties,
  [out]          ID2D1Bitmap1                    **bitmap
);

Parameters

[in] surface

Type: IDXGISurface*

The DXGI surface from which the bitmap can be created.

Note  The DXGI surface must have been created from the same Direct3D device that the Direct2D device context is associated with.
 

[in, optional] bitmapProperties

Type: const D2D1_BITMAP_PROPERTIES1*

The bitmap properties specified in addition to the surface.

[out] bitmap

Type: ID2D1Bitmap1**

When this method returns, contains the address of a pointer to a new bitmap object.

Return value

Type: HRESULT

The method returns an HRESULT. Possible values include, but are not limited to, those in the following table.

HRESULT Description
S_OK No error occurred.
E_OUTOFMEMORY Direct2D could not allocate sufficient memory to complete the call.
E_INVALIDARG An invalid value was passed to the method.
D3DERR_OUTOFVIDEOMEMORY Direct3D does not have enough display memory to perform the operation.

Remarks

If the bitmap properties are not specified, the following information is assumed:

  • The bitmap DPI is 96.
  • The pixel format matches that of the surface.
  • The returned bitmap will inherit the bind flags of the DXGI surface.
    • However, only the subset of flags meaningful to Direct2D will be inherited. For example, D3D10_USAGE_DYNAMIC is not compatible with any public Direct2D flags.
  • The color context is unknown.
  • The alpha mode of the bitmap will be premultiplied (common case) or straight (A8).
If the bitmap properties are specified, the bitmap properties will be used as follows:
  • The bitmap DPI will be specified by the bitmap properties.
  • If both dpiX and dpiY are 0, the bitmap DPI will be 96.
  • The pixel format must be compatible with the shader resource view or render target view of the surface.
  • The bitmap options must be compatible with the bind flags of the DXGI surface. However, they may be a subset. This will influence what resource views are created by the bitmap.
  • The color context information will be used from the bitmap properties, if specified.

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

See also

D2D1_BITMAP_PROPERTIES1

ID2D1Bitmap1

ID2D1DeviceContext

ID2D1DeviceContext::SetTarget