Icon image loses quality after deserialization
-
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
-
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
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;
-
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;
I meant, in this example no image quality loss can be observed.