开发者

Non-Smooth Upscaling with graphics.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 followi开发者_JS百科ng 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?


I think you should change InterpolationMode property of your graphics. Aslo take a look into SmoothingMode and CompositingQuality of Graphics class.


There's two things that might work.

  • Try to experiment with the InterpolationMode property on your Graphics object. Unfortunately, off the top of my head, I don't know which setting woud work better than the default.
  • Try using a ScaleTransform on your Graphics object (an remember to reset it when you're done).
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜