Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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?

like image 506
ohmusama Avatar asked Apr 21 '11 08:04

ohmusama


1 Answers

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

like image 89
Anton Semenov Avatar answered Sep 20 '22 13:09

Anton Semenov