Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Saving Images ...

Reply
 
Old 11-19-2008   #1 (permalink)
Tom


 
 

Saving Images ...

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.


My System SpecsSystem Spec
Old 11-19-2008   #2 (permalink)
Tom


 
 

Re: Saving Images ...


"Peter Duniho" <NpOeStPeAdM@xxxxxx> wrote in message
newsp.ukv6efrt8jd0ej@xxxxxx-computer.local...
Quote:

> On Wed, 19 Nov 2008 16:00:24 -0800, Tom <johnthompson1@xxxxxx> wrote:
>
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.

My System SpecsSystem Spec
Old 11-19-2008   #3 (permalink)
Peter Duniho


 
 

Re: Saving Images ...

On Wed, 19 Nov 2008 17:05:45 -0800, Tom <johnthompson1@xxxxxx> wrote:
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
My System SpecsSystem Spec
Old 11-19-2008   #4 (permalink)
Tom


 
 

Re: Saving Images ...


"Peter Duniho" <NpOeStPeAdM@xxxxxx> wrote in message
newsp.ukv8dqai8jd0ej@xxxxxx-computer.local...
Quote:

> On Wed, 19 Nov 2008 17:05:45 -0800, Tom <johnthompson1@xxxxxx> wrote:
>
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.

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Sounds Simple but very important; Trouble saving a webpage with images Offline. Vista file management
Saving images from internet Vista file management
Getty Images and View Images Can't view Vista General
Saving Images, etc. Vista music pictures video
Creating and saving Stationary with own images Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46