Click here to Skip to main content
15,918,333 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

Can any one share the sample to serialize Image to XML type

Regards,

sajith
Posted

1 solution

SQL
[XmlIgnore]
public Bitmap LargeIcon { get; set; }

[Browsable(false),EditorBrowsable(EditorBrowsableState.Never)]
[XmlElement("LargeIcon")]
public byte[] LargeIconSerialized
{
    get { // serialize
        if (LargeIcon == null) return null;
        using (MemoryStream ms = new MemoryStream()) {
            LargeIcon.Save(ms, ImageFormat.Bmp);
            return ms.ToArray();
        }
    }
    set { // deserialize
        if (value == null) {
            LargeIcon = null;
        } else {
            using (MemoryStream ms = new MemoryStream(value)) {
                LargeIcon = new Bitmap(ms);
            }
        }
    }
}
 
Share this answer
 
Comments
sajithnet 19-Mar-12 3:56am    
can u please send the full code
Sushil Mate 19-Mar-12 5:26am    
Please refer this article.

http://www.codeproject.com/Articles/4491/Load-and-save-objects-to-XML-using-serialization
sajithnet 19-Mar-12 6:35am    
thanks
Sushil Mate 19-Mar-12 7:05am    
welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900