Serializing an object containing a Bitmap i .NET Compact Framework
I am writing a project for Windows mobile 6 (.NET CF 3.5). My project contains a class that looks like this:
class MyClass {
private Bitmap picture;
//... and some o开发者_如何学Cther fields ...
public MyClass ()
{
picture = new Bitmap (/*Picture file path*/);
//...
}
}
To my surprise, I found out that there is no binary formatter in the .NET CF. Does anyone know how can I serialize such object?? I tried to use CompactFormatterPlus - but it didnt worked.
There are two ways to attack this.
- Manually serialize it. The Bitmap class has a Save method that can output to a Stream. You could send that to your serialization stream.
- Use a third-party option. I'd likely use protobuf-net.
精彩评论