使用 Graphics.DrawImage 进行非平滑升级
我正在网格中绘制一些图像。图像保存为 16x16px png。
然而,我后来决定将网格的大小增加到 32x32px。
当我使用以下代码时:
graphics.DrawImage(image, Xdraw, Ydraw, 32, 32);
其中 image 是从 png 加载的图像,Xdraw 和 Ydraw 是上面确定的左上角。
图像有点模糊,因为 .DrawImage 使用双三次(或其他一些平滑函数)来放大图像。我希望它关闭平滑,这样我就可以保留硬边缘。
这可能吗?
I am drawing some images in a grid. The images are saved as 16x16px pngs.
However, I later decided to up the size of the grid to 32x32px.
When I use the following code:
graphics.DrawImage(image, Xdraw, Ydraw, 32, 32);
where image is an Image loaded from a png, and Xdraw and Ydraw are the top left corner decided somewhere above.
The image is slightly blurry as .DrawImage uses bicubic(or some other smoothing function) to upscale the image. I would like it to turn the smoothing off, so I can preserve the hard edges.
Is this possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你应该更改图形的
InterpolationMode
属性。还可以查看 Graphics 类的SmoothingMode
和CompositingQuality
。I think you should change
InterpolationMode
property of your graphics. Aslo take a look intoSmoothingMode
andCompositingQuality
of Graphics class.有两件事可能有效。
There's two things that might work.