Hi folks,
I've made a test bitmap file in Photoshop with 100 x 100 size and it
is only white. Now I'm getting a thumbnail from this image and the
result is that this image is not white. This function makes a gray
border on the left and on the top. Is this a bug? This function is
from this site http://www.bobpowell.net/highqualitythumb.htm. I just
changed the PixelFormat to get a 24 bit bitmap as a output.
if (Percentage < 1)
{
throw new Exception("Thumbnail size");
}
Bitmap tn =
new Bitmap((int) (Orginal.Width*0.01F*Percentage),
(int) (Orginal.Height*0.01F*Percentage), PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(tn);
g.InterpolationMode =
InterpolationMode.HighQualityBilinear;
g.DrawImage(Orginal, new Rectangle(0, 0, tn.Width,
tn.Height), 0, 0, Orginal.Width, Orginal.Height,
GraphicsUnit.Pixel);
g.Dispose();
return tn;
Bob Powell [MVP] - 16 May 2008 22:11 GMT
This is due to the fact that interpolated images try to interpolate the
values _outside_ of the image and so tend to mix in some black. You could
make the thumbnail from a rectangle just a few pixels smaller than the
actual image.

Signature
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
> Hi folks,
>
[quoted text clipped - 23 lines]
>
> return tn;
Bob Powell [MVP] - 17 May 2008 15:41 GMT
This is because the interpolation mode stupidly tries to interpolate the
pixels outside of the image. The only way to avoid it is to use a portion of
the image a few pixels in from each edge.

Signature
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting
http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
> Hi folks,
>
[quoted text clipped - 23 lines]
>
> return tn;
Bob Powell [MVP] - 21 May 2008 19:50 GMT
ha, i wondered if this had ever been sent...
> This is because the interpolation mode stupidly tries to interpolate the
> pixels outside of the image. The only way to avoid it is to use a portion
[quoted text clipped - 27 lines]
>>
>> return tn;
Carlos Alloatti - 22 May 2008 06:34 GMT
Solution for this here:
http://decenturl.com/groups.google/resizing-image-defect-strange
Carlos Alloatti