I am using ID2D1RenderTarget::CreateBitmap
from D2D1.h
to create ID2D1Bitmap
from array of pixels but this function returns 0x88982f80 (WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT) and ID2D1Bitmap*
is NULL
There is a code to create a bitmap:
hr = m_pRenderTarget->CreateBitmap(
D2D1::SizeU(10, 10), src, 4 * 10,
D2D1::BitmapProperties(D2D1::PixelFormat(DXGI_FORMAT_R8G8B8A8_UNORM, D2D1_ALPHA_MODE_STRAIGHT)),
&bitmap
);
if (hr < 0) exit(1); // IF FAILED EXIT WITH CODE 1
How to fix that?
The solution is simple:
hr = m_pRenderTarget->CreateBitmap(
D2D1::SizeU(10, 10), src, 4 * 10,
D2D1::BitmapProperties(D2D1::PixelFormat(
DXGI_FORMAT_R8G8B8A8_UNORM,
D2D1_ALPHA_MODE_PREMULTIPLIED)
),
&bitmap
);
Supported alpha modes for DXGI_FORMAT_R8G8B8A8_UNORM are:
You can also change the rendering parameters of ID2D1RenderTarget
(D2D1_RENDER_TARGET_PROPERTIES
) to achieve the result.
The full list of supported alpha modes for each DXGI_FORMAT
you can see here: Supported Pixel Formats and Alpha Modes .
User contributions licensed under CC BY-SA 3.0