相当于 Gdi+ 中的 MM_ISOTROPIC 映射模式
我有一些使用各向同性映射模式的 C++/GDI 绘图代码。 我有一个大型对象模型,其中包含大量绘图代码,我试图在 C# 项目中重用这些代码来绘制内存位图。 我在正确设置 System.Graphics 对象以生成相同的图片时遇到问题。 有没有办法在 System.Graphics 对象中设置与 MM_ISOTROPIC 映射模式等效的方法?
以下是 C++/GDI 中准备映射模式的相关代码。
CDC* pDC = ...
pDC->SetMapMode(MM_ISOTROPIC);
pDC->SetWindowExt(24, 24);
pDC->SetViewportExt(pDC->GetDeviceCaps(LOGPIXELSX), pDC->GetDeviceCaps(LOGPIXELSY));
I have some C++/GDI drawing code that uses the isotropic mapping mode. I have a large object model with lots of drawing code that I'm trying to reuse in a C# project to draw to an in memory bitmap. I'm having problems setting up the System.Graphics object properly to produce the same picture. Is there any way of setting up the equivalent of the MM_ISOTROPIC mapping mode in a System.Graphics object?
Here is the relevant code from C++/GDI that prepares the mapping mode.
CDC* pDC = ...
pDC->SetMapMode(MM_ISOTROPIC);
pDC->SetWindowExt(24, 24);
pDC->SetViewportExt(pDC->GetDeviceCaps(LOGPIXELSX), pDC->GetDeviceCaps(LOGPIXELSY));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MM_ISOTROPIC 没有什么特别的,它只是确保 X 和 Y 缩放相同,即使您给它的值与 SetViewportExt() 和 SetWindowExt() 相冲突。 但你不知道。 我认为没有任何硬件没有方形像素。
无论如何,只要确保将相同的值传递给 Graphics.ScaleTransform() 即可。
There's nothing special about MM_ISOTROPIC, it just makes sure that the X- and Y-scaling is identical, even if you give it conflicting values with SetViewportExt() and SetWindowExt(). Which you don't. I don't think there's any hardware left that doesn't have square pixels.
Anyhoo, just make sure you pass equal values to Graphics.ScaleTransform().