Connecting Tech Pros Worldwide Help | Site Map

Saving Images ...

  #1  
Old November 20th, 2008, 12:15 AM
Tom
Guest
 
Posts: n/a
I have a Metafile that I would like to save as an image. So far, this seems
to work fine:

Metafile x = new Metafile(myFilename);
x.Save(jpgFilename, ImageFormat.Jpeg);

While I get the image fine, the background is black. For the life of me, I
can't figure out how to make the background white. Any ideas?

Somebody please make me feel stupid. Thanks.

  #2  
Old November 20th, 2008, 12:35 AM
Peter Duniho
Guest
 
Posts: n/a

re: Saving Images ...


On Wed, 19 Nov 2008 16:00:24 -0800, Tom <johnthompson1@hotmail.comwrote:
Quote:
I have a Metafile that I would like to save as an image. So far, this
seems to work fine:
>
Metafile x = new Metafile(myFilename);
x.Save(jpgFilename, ImageFormat.Jpeg);
>
While I get the image fine, the background is black. For the life of
me, I can't figure out how to make the background white. Any ideas?
Black is the color of default-initialized pixels (0 for all components).
You have two options: modify the metafile so that it explicitly fills a
white background behind itself, or draw the metafile into a Bitmap
instance you've cleared to white and save the Bitmap instead of the
metafile.

Pete
  #3  
Old November 20th, 2008, 01:15 AM
Tom
Guest
 
Posts: n/a

re: Saving Images ...



"Peter Duniho" <NpOeStPeAdM@nnowslpianmk.comwrote in message
news:op.ukv6efrt8jd0ej@petes-computer.local...
Quote:
On Wed, 19 Nov 2008 16:00:24 -0800, Tom <johnthompson1@hotmail.comwrote:
>
Quote:
>I have a Metafile that I would like to save as an image. So far, this
>seems to work fine:
>>
>Metafile x = new Metafile(myFilename);
>x.Save(jpgFilename, ImageFormat.Jpeg);
>>
>While I get the image fine, the background is black. For the life of
>me, I can't figure out how to make the background white. Any ideas?
>
Black is the color of default-initialized pixels (0 for all components).
You have two options: modify the metafile so that it explicitly fills a
white background behind itself, or draw the metafile into a Bitmap
instance you've cleared to white and save the Bitmap instead of the
metafile.
>
Pete
Thank you Pete. I'm up for either of those 2 options (probably prefer the
Bitmap), but I can't find any example code anywhere to get me started. How
would I draw the Metafile object into a Bitmap object that has been cleared
to a white background?

Thanks again.

  #4  
Old November 20th, 2008, 01:15 AM
Peter Duniho
Guest
 
Posts: n/a

re: Saving Images ...


On Wed, 19 Nov 2008 17:05:45 -0800, Tom <johnthompson1@hotmail.comwrote:
Quote:
Thank you Pete. I'm up for either of those 2 options (probably prefer
the Bitmap), but I can't find any example code anywhere to get me
started. How would I draw the Metafile object into a Bitmap object that
has been cleared to a white background?
See the Graphics and Bitmap classes. In particular, create your
destination Bitmap, call Graphics.FromImage(), then draw whatever you want
with that Graphics instance (see Graphics.Clear() and Graphics.DrawImage()
for inspiration).

Don't forget to dispose your IDisposables. :)

Pete
  #5  
Old November 20th, 2008, 01:55 AM
Tom
Guest
 
Posts: n/a

re: Saving Images ...



"Peter Duniho" <NpOeStPeAdM@nnowslpianmk.comwrote in message
news:op.ukv8dqai8jd0ej@petes-computer.local...
Quote:
On Wed, 19 Nov 2008 17:05:45 -0800, Tom <johnthompson1@hotmail.comwrote:
>
Quote:
>Thank you Pete. I'm up for either of those 2 options (probably prefer
>the Bitmap), but I can't find any example code anywhere to get me
>started. How would I draw the Metafile object into a Bitmap object that
>has been cleared to a white background?
>
See the Graphics and Bitmap classes. In particular, create your
destination Bitmap, call Graphics.FromImage(), then draw whatever you want
with that Graphics instance (see Graphics.Clear() and Graphics.DrawImage()
for inspiration).
>
Don't forget to dispose your IDisposables. :)
>
Pete
Thanks again Pete. I'll check it out.

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving images in Excel report Eddie answers 6 June 27th, 2008 05:15 PM
Desperately needing direction with EncoderParameters and saving images under different compression/quality schemes NutsAboutVB answers 6 May 1st, 2006 05:25 PM
Desperately needing direction with EncoderParameters and saving images under different compression/quality schemes NutsAboutVB answers 1 May 1st, 2006 05:45 AM
Help when saving images to bitmap files M Keeton answers 1 November 23rd, 2005 04:42 AM
Saving Images While Saving ASP Pages ! Lovely Angel For You answers 1 July 19th, 2005 08:43 AM