D2D1_PIXEL_FORMAT structure (dcommon.h)
Contains the data format and alpha mode for a bitmap or render target.
Syntax
typedef struct D2D1_PIXEL_FORMAT {
DXGI_FORMAT format;
D2D1_ALPHA_MODE alphaMode;
} D2D1_PIXEL_FORMAT;
Members
format
Type: DXGI_FORMAT
A value that specifies the size and arrangement of channels in each pixel.
alphaMode
Type: D2D1_ALPHA_MODE
A value that specifies whether the alpha channel is using pre-multiplied alpha, straight alpha, whether it should be ignored and considered opaque, or whether it is unknown.
Remarks
For more information about the pixel formats and alpha modes supported by each render target, see Supported Pixel Formats and Alpha Modes.
Examples
The following example creates a D2D1_PIXEL_FORMAT structure and uses it to specify the pixel format and alpha mode of an ID2D1HwndRenderTarget.
RECT rc;
GetClientRect(m_hwnd, &rc);
D2D1_SIZE_U size = D2D1::SizeU(
rc.right - rc.left,
rc.bottom - rc.top
);
// Create a pixel format and initial its format
// and alphaMode fields.
D2D1_PIXEL_FORMAT pixelFormat = D2D1::PixelFormat(
DXGI_FORMAT_B8G8R8A8_UNORM,
D2D1_ALPHA_MODE_IGNORE
);
D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties();
props.pixelFormat = pixelFormat;
// Create a Direct2D render target.
hr = m_pD2DFactory->CreateHwndRenderTarget(
props,
D2D1::HwndRenderTargetProperties(m_hwnd, size),
&m_pRT
);
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista [desktop apps | UWP apps] |
Minimum supported server | Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008 [desktop apps | UWP apps] |
Header | dcommon.h (include D2d1.h) |