Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image border missing after downscaling

When I resize a bitmap using Graphics class, it seams that some right and bottom pixels of the original image are omited.

Here is an example (original, 60x60, 30x30):

original result60 result30

my code:

foreach(int x in new[]{60, 30})
{
    var result = new Bitmap(x, x);
    var g = Graphics.FromImage(result);
    g.DrawImage(new Bitmap(MediaDir + "original.png"), 0, 0, x, x);
    result.Save(MediaDir + "result" + x + ".png", ImageFormat.Png);
}

Am I missing something ?

edit, here is the result using HighQualityBicubic:

enter image description here enter image description here enter image description here enter image description here

like image 713
Tom Esterez Avatar asked Aug 04 '26 05:08

Tom Esterez


1 Answers

Set the interpolation mode to InterpolationMode.HighQualityBicubic.

You can see the effects of the parameter in a Microsoft Tutorial. The bottom left example has similar problems to yours.

like image 127
Mark Ransom Avatar answered Aug 05 '26 18:08

Mark Ransom



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!