Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Drawing / May 2008

Tip: Looking for answers? Try searching our database.

Thumbnail from a white image makes a gray border...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Timur Zanagar (ClockWorkZ) - 14 May 2008 08:26 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.