カスタム CAD ソフトウェアを GDI から Direct2D に変換中です。図面をパンするときに問題が発生します。私がやりたいことは、描画ウィンドウの幅の 3 倍、高さの 3 倍のビットマップを作成することです。次に、ユーザーがパンを開始すると、表示されるビットマップの部分をレンダリングします。
問題は、レンダー ターゲットよりも大きなビットマップを使用できるように見えないことです。これまでに行ったことはおおよそ次のとおりです。
// Get the size of my drawing window.
RECT rect;
HDC hdc = GetDC(hwnd);
GetClipBox(hdc, &rect);
D2D1_SIZE_U size = D2D1::SizeU(
rect.right - rect.left,
rect.bottom - rect.top
);
// Now create the render target
ID2D1HwndRenderTarget *hwndRT = NULL;
hr = m_pD2DFactory->CreateHwndRenderTarget(
D2D1::RenderTargetProperties(),
D2D1::HwndRenderTargetProperties(hwnd, size),
&hwndRT
);
// And then the bitmap render target
ID2D1BitmapRenderTarget *bmpRT = NULL;
// We want it 3x as wide & 3x as high as the window
D2D1_SIZE_F size = D2D1::SizeF(
(rect.right - rect.left) * 3,
(rect.bottom - rect.top) * 3
);
hr = originalTarget->CreateCompatibleRenderTarget(
size,
&bmpRT
);
// Now I draw the geometry to my bitmap Render target...
// Then get the bitmap
ID2D1Bitmap* bmp = NULL;
bmpRT->GetBitmap(&bmp);
// From here I want to draw that bitmap on my hwndRenderTarget.
// Based on where my mouse was when I started panning, and where it is
// now, I can create a destination rectangle. It's the size of my
// drawing window
D2D1_RECT_U dest = D2D1::RectU(x1, y1, x1+size.width, y1+size.height);
hwndRT->DrawBitmap(
bmp,
NULL,
1.0,
D2D1_BITMAP_INTERPOLATION_MODE_LINEAR,
dest
);
したがって、ビットマップのサイズを確認すると、問題なくチェックアウトされます。これは、hwnd レンダー ターゲットではなく、ビットマップ レンダー ターゲットのサイズです。しかし、x1 と y1 を 0 に設定すると、ビットマップの左上隅が描画されるはずです (これは画面外のジオメトリです)。ただし、画面に表示されているものの左上隅を描画するだけです。
誰もこれについて経験がありますか?かなり大きなビットマップを作成し、その一部をより小さいサイズのレンダー ターゲットにレンダリングするにはどうすればよいですか? 私はパンしているので、マウスが動くたびにレンダリングが行われるので、適度なパフォーマンスが必要です。