Microsoft Docs

D2D1_BITMAP_PROPERTIES

Structure that describes the pixel format and DPI settings for a bitmap.

Syntax

typedef struct D2D1_BITMAP_PROPERTIES {
    D2D1_PIXEL_FORMAT pixelFormat;
    D2D1_SIZE_F       dpi;
} D2D1_BITMAP_PROPERTIES;Copy

Members

MemberTypeDescription
pixelFormat D2D1_PIXEL_FORMAT Specifies the format of the bitmap's pixels. See D2D1_PIXEL_FORMAT.
dpi D2D1_SIZE_F Specifies the dots‑per‑inch (DPI) resolution of the bitmap in the X and Y dimensions.

Remarks

The pixelFormat member determines how the color data is stored. Common formats include DXGI_FORMAT_B8G8R8A8_UNORM and DXGI_FORMAT_R8G8B8A8_UNORM. The dpi member allows Direct2D to scale vector content appropriately when rendering the bitmap.

When creating a bitmap with ID2D1RenderTarget::CreateBitmap, pass a populated D2D1_BITMAP_PROPERTIES structure. If you need the default DPI (96), you can use the helper macro D2D1::BitmapProperties.

Example

// Create a bitmap with 32‑bit BGRA format and 96 DPI
D2D1_BITMAP_PROPERTIES props = D2D1::BitmapProperties(
    D2D1::PixelFormat(
        DXGI_FORMAT_B8G8R8A8_UNORM,
        D2D1_ALPHA_MODE_PREMULTIPLIED),
    96.0f, 96.0f);

ID2D1Bitmap* pBitmap = nullptr;
hr = pRenderTarget->CreateBitmap(
        D2D1::SizeU(256, 256),
        nullptr,
        0,
        &props,
        &pBitmap);
Copy

See Also