Saving Images ...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • 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(myFile name);
    x.Save(jpgFilen ame, ImageFormat.Jpe g);

    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.

  • Peter Duniho

    #2
    Re: Saving Images ...

    On Wed, 19 Nov 2008 16:00:24 -0800, Tom <johnthompson1@ hotmail.comwrot e:
    I have a Metafile that I would like to save as an image. So far, this
    seems to work fine:
    >
    Metafile x = new Metafile(myFile name);
    x.Save(jpgFilen ame, ImageFormat.Jpe g);
    >
    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

    Comment

    • Tom

      #3
      Re: Saving Images ...


      "Peter Duniho" <NpOeStPeAdM@nn owslpianmk.comw rote in message
      news:op.ukv6efr t8jd0ej@petes-computer.local. ..
      On Wed, 19 Nov 2008 16:00:24 -0800, Tom <johnthompson1@ hotmail.comwrot e:
      >
      >I have a Metafile that I would like to save as an image. So far, this
      >seems to work fine:
      >>
      >Metafile x = new Metafile(myFile name);
      >x.Save(jpgFile name, ImageFormat.Jpe g);
      >>
      >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.

      Comment

      • Peter Duniho

        #4
        Re: Saving Images ...

        On Wed, 19 Nov 2008 17:05:45 -0800, Tom <johnthompson1@ hotmail.comwrot e:
        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.FromIm age(), then draw whatever you want
        with that Graphics instance (see Graphics.Clear( ) and Graphics.DrawIm age()
        for inspiration).

        Don't forget to dispose your IDisposables. :)

        Pete

        Comment

        • Tom

          #5
          Re: Saving Images ...


          "Peter Duniho" <NpOeStPeAdM@nn owslpianmk.comw rote in message
          news:op.ukv8dqa i8jd0ej@petes-computer.local. ..
          On Wed, 19 Nov 2008 17:05:45 -0800, Tom <johnthompson1@ hotmail.comwrot e:
          >
          >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.FromIm age(), then draw whatever you want
          with that Graphics instance (see Graphics.Clear( ) and Graphics.DrawIm age()
          for inspiration).
          >
          Don't forget to dispose your IDisposables. :)
          >
          Pete
          Thanks again Pete. I'll check it out.

          Comment

          Working...