none
Are Imageframe and SkeletonData serializable? RRS feed

  • Question

  • Are Imageframe and SkeletonData marked as serializable?

    I need to do a serialization, could you give an briefly example in C# for the ImageFrame class?

    I'm new in C# and I'm confused to do that .

    Tuesday, August 23, 2011 8:32 PM

Answers

  • No, they are not marked as serializable.

    If you want to serialize structure you'll have to serialize element by element. E.g.:

    using System.Runtime.Serialization;
    using System.Runtime.Serialization.Formatters;
    using System.Runtime.Serialization.Formatters.Binary;
    using System.IO;
    
    ...
    
    using (FileStream stream = new FileStream("foo.srl", FileMode.Create, FileAccess.Write, FileShare.None))
    {
      IFormatter formatter = new BinaryFormatter();
    
      formatter.Serialize(stream, e.ImageFrame.Timestamp);
      formatter.Serialize(stream, e.ImageFrame.FrameNumber);
      formatter.Serialize(stream, e.ImageFrame.Type);
      formatter.Serialize(stream, e.ImageFrame.Resolution);
      formatter.Serialize(stream, e.ImageFrame.Timestamp);
      formatter.Serialize(stream, e.ImageFrame.Flags);
      formatter.Serialize(stream, e.ImageFrame.Image.Width);
      formatter.Serialize(stream, e.ImageFrame.Image.Height);
      formatter.Serialize(stream, e.ImageFrame.Image.BytesPerPixel);
      formatter.Serialize(stream, e.ImageFrame.Image.Bits);
      formatter.Serialize(stream, e.ImageFrame.ViewArea.Zoom);
      formatter.Serialize(stream, e.ImageFrame.ViewArea.CenterX);
      formatter.Serialize(stream, e.ImageFrame.ViewArea.CenterY);
    }

    Eddy


    I'm here to help
    Wednesday, August 24, 2011 11:09 PM