How to resize a bitmap image in C# without blending or filtering?

hrh picture hrh · Jul 12, 2012 · Viewed 14.2k times · Source

I have a gray scale image that I would like to enlarge so that I can better see the individual pixels. I've tried setting Smoothing mode to none and some different Interpolation Modes (as suggested on other questions on here), but the images still appear to me as if they are still doing some sort of blending before being displayed on the screen.

basically If I have a image that is

(White, White,
 White, Black)

I want when I enlarge it to say 6x6, it to look like

 (White, White, White, White, White, White
  White, White, White, White, White, White
  White, White, White, White, White, White
  White, White, White, Black, Black, Black
  White, White, White, Black, Black, Black
  White, White, White, Black, Black, Black)

With no fading between the black and white areas, should look like a square. The image should look more "pixelized" rather then "Blurry"

Answer

Raman Zhylich picture Raman Zhylich · Jul 12, 2012

Try to set interpolation mode:

g.InterpolationMode = InterpolationMode.NearestNeighbor;