C#C
C#12mo ago
Silme94

Bad Bitmap quality

on the right, the original image, on the left, the saved image from bitmap (im doing a functionnality to add image to image). As you can see, there is a big quality difference. Is there a way to keep the same quality?

using (Bitmap bitmap = new Bitmap(pageImage.Width, pageImage.Height))
{

    bitmap.SetResolution(96, 96);

    using (Graphics g = Graphics.FromImage(bitmap))
    {

        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
        g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;

       
        var rect = new Rectangle(0, 0, pageImage.Width, pageImage.Height);
        pageImage.DrawToBitmap(bitmap, rect);
    }


    bitmap.Save(@"C:\Users\silme\Desktop\img.png", ImageFormat.Png);
}
poi.PNG
Was this page helpful?