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. Icon image loses quality after deserialization

Icon image loses quality after deserialization

Scheduled Pinned Locked Moved C#
cssquestion
3 Posts 2 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.
  • F Offline
    F Offline
    Flack
    wrote on last edited by
    #1

    Hello, In my app I have a custom button class that contains an Icon field. I choose an icon for the button, save this icon in the buttons icon field and set the icon to be displayed on the button. So far everything works great and the icon on the button looks fine. Now, I want to save the button's icon (along with other info Im using), so I serialize it. However, when I deserialize the info and create a new button using the deserialized icon, the icons image quality is poor. It looks like its using less colors or something. The same thing happened when I used bitmaps intstead of icons. I dont have much experience with image manipulation so if anyone knows what could be causing the drop in quality please let me know. (Is there a way to set the image quality of the deserialized icon to that of windows)? Thanx :-D -Flack

    U 1 Reply Last reply
    0
    • F Flack

      Hello, In my app I have a custom button class that contains an Icon field. I choose an icon for the button, save this icon in the buttons icon field and set the icon to be displayed on the button. So far everything works great and the icon on the button looks fine. Now, I want to save the button's icon (along with other info Im using), so I serialize it. However, when I deserialize the info and create a new button using the deserialized icon, the icons image quality is poor. It looks like its using less colors or something. The same thing happened when I used bitmaps intstead of icons. I dont have much experience with image manipulation so if anyone knows what could be causing the drop in quality please let me know. (Is there a way to set the image quality of the deserialized icon to that of windows)? Thanx :-D -Flack

      U Offline
      U Offline
      User 929285
      wrote on last edited by
      #2

      Button button1=new Button(); button1.Parent=this; button1.Bounds=new Rectangle(20,20,256,256); button1.Image=new Bitmap(@"C:\Windows\soap bubbles.bmp"); FileStream fs=new FileStream("iconser.bin",FileMode.OpenOrCreate,FileAccess.Write,FileShare.None); BinaryFormatter bf=new BinaryFormatter(); bf.Serialize(fs,button1.Image); fs.Flush(); fs.Close(); FileStream fsOut=new FileStream("iconser.bin",FileMode.Open,FileAccess.Read,FileShare.None); Image img=(Image)bf.Deserialize(fsOut); Button btn=new Button(); btn.Bounds=new Rectangle(300,20,256,256); btn.Parent=this; btn.Image=img;

      U 1 Reply Last reply
      0
      • U User 929285

        Button button1=new Button(); button1.Parent=this; button1.Bounds=new Rectangle(20,20,256,256); button1.Image=new Bitmap(@"C:\Windows\soap bubbles.bmp"); FileStream fs=new FileStream("iconser.bin",FileMode.OpenOrCreate,FileAccess.Write,FileShare.None); BinaryFormatter bf=new BinaryFormatter(); bf.Serialize(fs,button1.Image); fs.Flush(); fs.Close(); FileStream fsOut=new FileStream("iconser.bin",FileMode.Open,FileAccess.Read,FileShare.None); Image img=(Image)bf.Deserialize(fsOut); Button btn=new Button(); btn.Bounds=new Rectangle(300,20,256,256); btn.Parent=this; btn.Image=img;

        U Offline
        U Offline
        User 929285
        wrote on last edited by
        #3

        I meant, in this example no image quality loss can be observed.

        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