Resizing an Binarized image in C#
- by mouthpiec
Hi,
I have the following code to resize a Binarized image (hence pixel value is 0[black] or 255[white]) with the following code
Bitmap ResizedCharImage = new Bitmap(newwidth, newheight);
using (Graphics g = Graphics.FromImage((Image)ResizedCharImage))
{
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
g.SmoothingMode = SmoothingMode.HighQuality;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.DrawImage(CharBitmap, new Rectangle(0, 0, newwidth, newheight),
new Rectangle(0, 0, CharBitmap.Width, CharBitmap.Height), GraphicsUnit.Pixel);
}
The problem that I am having is that when resizing (i am enlarging the image) some of the pixel values become 254, 253, 1, 2 etc. I need that this do not occur. Is this possible, maybe by changing one of the Graphins properties?