如何将窗口的一部分绘制到内存设备上下文中?
我使用简单的语句来保持它,呃,简单:
- 屏幕从 0, 0 到 1000, 1000(屏幕坐标)。
- 窗口从 100、100 到 900、900(屏幕坐标)。
- 我有一个从 0, 0 到 200, 200(逻辑坐标)的内存设备上下文。
我需要向窗口发送 WM_PRINT 消息。我可以通过 WM_PRINT 将设备上下文传递到窗口,但我无法传递应将其窗口的哪一部分绘制到设备上下文中。
是否有某种方法可以更改设备上下文,从而导致窗口将其自身的特定部分绘制到设备上下文中(例如,其右下部分从 700、700 到 900、900)?
(这都是在普通的旧 GDI 和 C 或 C++ 中进行的。任何解决方案也必须如此。)
请注意: 这个问题是更大解决方案的一部分,其中设备上下文大小是固定的,速度至关重要,因此我无法将窗口完整绘制到单独的设备上下文中,并将我想要的部分从生成的完整位图中传输到我的设备上下文中。
I'm using simple statements to keep it, er, simple:
- The screen goes from 0, 0 to 1000, 1000 (screen coordinates).
- A window goes from 100, 100 to 900, 900 (screen coordinates).
- I have a memory device context that goes from 0, 0 to 200, 200 (logical coordinates).
I need to send a WM_PRINT message to the window. I can pass the device context to the window via WM_PRINT, but I cannot pass which part of its window it should draw into the device context.
Is there some way to alter the device context that will result in the window drawing a specific part of itself into the device context (say, its bottom right portion from 700, 700 to 900, 900)?
(This is all under plain old GDI and in C or C++. Any solution must be too.)
Please note:
This problem is part of a larger solution in which the device context size is fixed and speed is crucial, so I cannot draw the window in full into a separate device context and blit the part I want from the resultant full bitmap into my device context.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以调用 SetViewportOrgEx() 来指定将映射到窗口原点的设备上下文坐标:
由于窗口大小为
800x800
,因此将 DC 坐标系偏移-600x-600
将导致 < code>200x200 正在绘制窗口的右下区域,其余部分被剪切。You can call SetViewportOrgEx() to specify the device context coordinates that will be mapped to the window's origin:
Since your window's size is
800x800
, offsetting the DC's coordinate system by-600x-600
will result in the200x200
bottom right area of the window being drawn, and the rest being clipped.