Delphi Serialize
Serialization/Deserialization of BitmapBitmap corolla = new Bitmap ( @'C:corolla.jpg', true ); // some image file.MemoryStream ms = new MemoryStream ;corolla.Save(ms, System.Drawing.Imaging. ImageFormat.Jpeg);StringWriter sw = new StringWriter ;XmlTextWriter xw = new XmlTextWriter (sw);xw.Formatting = Formatting.Indented;XmlSerializer ser = new XmlSerializer (ms.GetBuffer.GetType);ser.Serialize(xw, ms.GetBuffer);Console.WriteLine( 'Serialized Content::' );string sSerializedContent = sw.GetStringBuilder.ToString;Console.WriteLine(sSerializedContent);xw.Close;//DeserializeXmlTextReader xrw = new XmlTextReader ( new StringReader (sSerializedContent));corolla = new Bitmap (new MemoryStream (( byte )ser.Deserialize(xrw)));corolla.Save( ' );xrw.Close;HTH. Indian Ocean.I understand that the Bitmap.Save can help to serialize the image data to a byte stream. However, I would like to stick with a Bitmap object, i.e. The serialized xml should reside in element and with corresponding Bitmap properties element under it.
I did tried to create my own serializer inherited from XmlSerializer, however, the overrided Serialize method does not get called anyway.When I look at it in Reflector, I found out that the Serialize method first call the abstrac API, CreateWriter, of the XmlSerializer base class. This API suppose to return a XmlSerializationWriter object which is documented as.Net Framework internal class and not to be used by us. I have no ideas on how to implement a XmlSerializer subclass at the moment. Any suggestion?
The serialization of Bitmap directly will not give you the serialized data of actual bitmap because BitMap object will not have it with it. Its similar like FileInfo that FileInfo is information about File but not actual file in it, you need to use FileStream to get the content and same way BitMap is information about the image but not having actual content so you will need to somehow save the content in stream and then you need to serialize that stream for which i have given above an example2. If you want to do that using your custom serializer then also internally you will need to do the same thing3. In your custom serializer, Serialize method will not be called because it has different parameters and its protected.Please have a look at the following link. This thread is not relavant to you but it has the code which may help you under 'Re: Config Load Time' heading written by Piotr.He shown code for custom xml serializer from Enterprise lib somewhere.HTH.
Delphi Json Serialization
Another solution, working from Delphi 5 up to XE2, is available.In fact, it implements:. Some low-level RTTI functions for handling record types: RecordEquals, RecordSave, RecordSaveLength, RecordLoad;.
Delphi Serialize Object Xml
A dedicated TDynArray object, which is a wrapper around any dynamic array, able to expose TList-like methods around any dynamic array, even containing records, strings, or other dynamic arrays. It's able to serialize any dynamic array.Serialization uses an optimized binary format, and is able to save and load any record or dynamic array as RawByteString. You have also JSON serialization at hand, including custom layout - see.
Introduction NG SerializerPack provides the ability to serialize/de-serialize Delphi objects into various storage formats. Any public (not only published!) property can be automatically handled by the engine. This allows to write data applications in a more object oriented and simpler way.