Re: image graphics drawing confusion

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Bob Powell [MVP] (bob_at__spamkiller_bobpowell.net)
Date: 07/30/04


Date: Fri, 30 Jul 2004 17:39:59 +0200

The GDI+ FAQ has articles on changing the resolution of an image and drawing
an image that will explain the process in more detail. Here's how to reduce
an image to 50% it's size...

Bitmap bm=Bitmap.FromFile("myImage.bmp");
Bitmap tmp=new Bitmap(bm.Width/2, bm.Height/2);
Graphics g=Graphics.FromImage(tmp);
g.DrawImage(bm,new
Rectangle(0,0,tmp.Width,tmp.Height),0,0,bm.Width,bm.Height,GraphicsUnit.Pixe
l);
g.Dispose();
bm.Dispose();
tmp.Save(......); // save the half-size file

Some JPEG images have a pre-defined thumbnail. This would have been
generated before you modified the image. I'm assuming that you changed the
bits for the main image, saved the thing, including the old thumbnail and
when you extract the thumbnail the software decides to use the old,
unchanged bits of the supplementary image, not the new ones.

-- 
Bob Powell [MVP]
Visual C#, System.Drawing
The Image Transition Library wraps up and LED style instrumentation is
available in the June of Well Formed for C# or VB programmers
http://www.bobpowell.net/currentissue.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm
The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml
"cwineman" <me@home.com> wrote in message news:410a4ec8$1_2@127.0.0.1...
> I don't understand. I take an image, and write some ellipses on it. Fine.
> Take that image and save it to disk and there it is with the ellipses
drawn
> on it. Good. Now, take the same image and create a thumbnail version of
it.
> Save it. Its a thumbnail, but there are no ellipses. Where did they go?
>
> If there are two different buffers how do I know which ones are going to
get
> used in different method calls? The Save() method uses a buffer that has
my
> modifications, but the GetThumbnailImage() doesn't? How does that make
> sense?
>
> How do I "create your own thumbnail by drawing the image to a correctly
> sized memory bitmap"? What methods do I use? Do you have a link to an
> example maybe?
>
> Thanks,
> -cwineman
>
>
> "Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
> news:uIoJgDcdEHA.4092@TK2MSFTNGP10.phx.gbl...
> > I think this problem comes from the fact that your AdjustImageSize
routine
> > gets a thumbnail image. This isn't drawn from the bits you've modified
but
> > from the thumbnail that already exists in the jpeg file.
> >
> > Rather than use the GetThumbnailImage method, create your own thumbnail
by
> > drawing the image to a correctly sized memory bitmap.
> >
> > -- 
> > Bob Powell [MVP]
> > Visual C#, System.Drawing
> >
> > The Image Transition Library wraps up and LED style instrumentation is
> > available in the June of Well Formed for C# or VB programmers
> > http://www.bobpowell.net/currentissue.htm
> >
> > Answer those GDI+ questions with the GDI+ FAQ
> > http://www.bobpowell.net/gdiplus_faq.htm
> >
> > The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
> > Windows Forms Tips and Tricks RSS:
http://www.bobpowell.net/tipstricks.xml
> > Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml
>
>


Relevant Pages

  • Re: Reducing image size dynamicaly
    ... The GDI+ FAQ has an article on modifying image resolution. ... > and presents it on the user browser, without doing tipical direct file ... > to be able to show a thumbnail of that image but, of course, much ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: Drawing irregular shapes with user interaction.
    ... libraries for this project, but I have other personal projects that ... will involve drawing, ... wrapped around GDI+? ... FAQ early on. ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: sideways text ??
    ... The GDI+ FAQ has an article on how to draw rotated text. ... All you ever wanted to know about ListView custom drawing is in Well Formed. ... "ian" wrote in message ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: image graphics drawing confusion
    ... The point I'm trying to make is that if the original file had a thumbnail it ... I handed the byte buffer to a memory stream ... Answer those GDI+ questions with the GDI+ FAQ ...
    (microsoft.public.dotnet.framework.drawing)
  • Re: converting image size
    ... Answer those GDI+ questions with the GDI+ FAQ ... but i need to save a copy of the image with different size then the original image but larger then the thumbnail. ... trying to use the Graphics class I didn't find the way to convert the image size. ...
    (microsoft.public.dotnet.framework.drawing)