限制 CView::onDraw() 中渲染图像的大小
在包含单个 CView 的 MFC SDI 应用程序中,我将输出设备上下文 pDC->m_hDC 传递到映射库以在 CMyView 中渲染地图: :OnDraw() 方法。
我希望渲染的图像出现在 cview 的中心,周围有黑色背景,即图像大小将小于 CView
客户端矩形大小。我已经尝试过 CDC::SetViewportOrg() 并在映射库中设置设备大小,但不幸的是映射库在设备大小设置之外绘制。
将图像限制为所需尺寸的最佳方法是什么?我应该考虑裁剪功能吗?或者我是否必须手动绘制图像中不需要的部分。
In a MFC SDI application containing a single CView
, I pass the output device context pDC->m_hDC
to a mapping library to render the map within the CMyView::OnDraw()
method.
I would like the rendered image to appear in the centre of the cview surrounded by a black background, i.e. the image size would be smaller than the CView
client rect size. I have experimented with CDC::SetViewportOrg()
and set the device size in the mapping library, however unfortunately the mapping library draws outside of the device size set.
What is the best way of limiting the image to the desired size? Should I be looking at clipping functions? Or do I have to manually draw over the undesired parts of the image.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么你可以通过两种方式做到这一点。
1) 你可以 SetBoundsRect 到你想要的边界。
2) 你可以将你想要的图像部分位 blt 到 DC 中。
方法 2 是我的首选方法,因为没有额外的逻辑。它甚至只会尝试绘制您正在传输的部分:)
Well you can do it 2 ways.
1) You could SetBoundsRect to the boundaries you want.
2) You could just bit blt the section of the image you want into the DC.
Method 2 would be my preferred method as there is no extra logic. It only ever even tries to draw the part you are blitting :)