I have to draw my shapes on a offscreen bitmap, but I have a strange problem when I try to render my bitmap.
This is how the image should be displayed:
And this how I a see the bitmap:
Following is the code I use to create the bitmap brush:
const auto size = renderTarget->GetSize();
const auto pxSize = D2D1::SizeU(size.width * 4, size.height * 4);
ID2D1BitmapRenderTarget* compatibleRenderTarget;
HRESULT hr = renderTarget->CreateCompatibleRenderTarget(size, pxSize, &compatibleRenderTarget);
if (SUCCEEDED(hr))
{
// compute visible area and the current transformation matrix
const auto area = get_visible_area(renderTarget);
const auto transform = D2D1::Matrix3x2F::Identity();
// offscreen bitmap rendering
compatibleRenderTarget->BeginDraw();
// draw all shapes
compatibleRenderTarget->EndDraw();
// Retrieve the bitmap from the render target.
ID2D1Bitmap* bitmap;
hr = compatibleRenderTarget->GetBitmap(&bitmap);
// release the compatible render target
compatibleRenderTarget->Release();
// Create the bitmap brush
ID2D1BitmapBrush* bitmapBrush = nullptr;
hr = renderTarget->CreateBitmapBrush(bitmap, D2D1::BitmapBrushProperties(), &bitmapBrush);
bitmap->Release();
// draw bitmap
renderTarget->FillRectangle(area, bitmapBrush);
}