I need to create a transparent bitmap using Direct2D and draw, by using my device context, on it.
ID2D1DeviceContext1* d2dContext = ...
ID2D1Bitmap* pBitmap;
d2dContext->CreateBitmap(
bitmapSize,
nullptr,
0,
D2D1::BitmapProperties1(
D2D1_BITMAP_OPTIONS_TARGET,
D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_PREMULTIPLIED),
dpiX, dpiY),
&pBitmap);
d2dContext->BeginDraw();
d2dContext->SetTarget(pBitmap);
d2dContext->Clear(D2D1::ColorF(0, 0));
d2dContext->DrawLine(...);
hr = d2dContext->EndDraw();
Unfortunately I am not able to create any transparent bitmaps. I tried with several pixel format combinations, including D2D1_ALPHA_MODE_STRAIGHT
, but without succeeding.
Is there any solution?