Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to serialize an image to a file

How to serialize an image to a file

Scheduled Pinned Locked Moved C#
graphicscomhelptutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Darryl Borden
    wrote on last edited by
    #1

    I need to get an image from the system clipboard (Clipboard.GetImage()) and serialize it to a file. The end goal would be to, at a later time, deserialize this image and put it back in the clipboard. I can't figure out how to successfully serialize the image. I tried creating a serializeable class that contains an image object, but I get the exception "The type System.Drawing.Bitmap was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically." I tried using XmlInclude but am either doing it wrong or it does not resolve the problem. Has someone done this before?

    Darryl Borden Principal IT Analyst dborden@eprod.com

    R A L 3 Replies Last reply
    0
    • D Darryl Borden

      I need to get an image from the system clipboard (Clipboard.GetImage()) and serialize it to a file. The end goal would be to, at a later time, deserialize this image and put it back in the clipboard. I can't figure out how to successfully serialize the image. I tried creating a serializeable class that contains an image object, but I get the exception "The type System.Drawing.Bitmap was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically." I tried using XmlInclude but am either doing it wrong or it does not resolve the problem. Has someone done this before?

      Darryl Borden Principal IT Analyst dborden@eprod.com

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      Will Image.Save()[^] work for you? /ravi

      My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

      1 Reply Last reply
      0
      • D Darryl Borden

        I need to get an image from the system clipboard (Clipboard.GetImage()) and serialize it to a file. The end goal would be to, at a later time, deserialize this image and put it back in the clipboard. I can't figure out how to successfully serialize the image. I tried creating a serializeable class that contains an image object, but I get the exception "The type System.Drawing.Bitmap was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically." I tried using XmlInclude but am either doing it wrong or it does not resolve the problem. Has someone done this before?

        Darryl Borden Principal IT Analyst dborden@eprod.com

        A Offline
        A Offline
        AspDotNetDev
        wrote on last edited by
        #3

        Please avoid cross-posting questions across forums. You don't need to waste the time of one of the people trying to answer your question after somebody else has already answered it.

        [Forum Guidelines]

        1 Reply Last reply
        0
        • D Darryl Borden

          I need to get an image from the system clipboard (Clipboard.GetImage()) and serialize it to a file. The end goal would be to, at a later time, deserialize this image and put it back in the clipboard. I can't figure out how to successfully serialize the image. I tried creating a serializeable class that contains an image object, but I get the exception "The type System.Drawing.Bitmap was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically." I tried using XmlInclude but am either doing it wrong or it does not resolve the problem. Has someone done this before?

          Darryl Borden Principal IT Analyst dborden@eprod.com

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          So you're saving an image as XML? This is why we need 1TB+ harddisks these days.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups