Resizing an Binarized image in C#

Posted by mouthpiec on Stack Overflow See other posts from Stack Overflow or by mouthpiec
Published on 2010-04-08T16:54:45Z Indexed on 2010/04/08 17:03 UTC
Read the original article Hit count: 324

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about image-resizing