开发者

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.

  1. Manually serialize it. The Bitmap class has a Save method that can output to a Stream. You could send that to your serialization stream.
  2. Use a third-party option. I'd likely use protobuf-net.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜