Saving Images ... 
November 20th, 2008, 12:15 AM
| | | |
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. | 
November 20th, 2008, 12:35 AM
| | | | 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 | 
November 20th, 2008, 01:15 AM
| | | | 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. | 
November 20th, 2008, 01:15 AM
| | | | 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 | 
November 20th, 2008, 01:55 AM
| | | | 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. |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,689 network members.
|