Reputation: 22157
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):
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:
Upvotes: 3
Views: 225
Reputation: 1
i used this workaround fot that "bug". When i resized standart eshop item photo, some have gray left/top border and some not. So u just use this code
g.DrawImage(src, -1, -1, width+1, height+1);
and its work perfectly. I also find some hints about pixelmode or try use some special attr with drawimage method but it doesnt work for me.
Upvotes: 0
Reputation: 29963
It is likely to be an effect of the resizing process itself. Depending on the algorithm used, it may be detecting the red colour of the pixels at the border as being no longer as relevant to the overall image as the white ones, so the white on is output.
Upvotes: 2
Reputation: 308462
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.
Upvotes: 3