private static void WriteIM(BinaryWriter bw, ImageManipulation im)
 {
     bw.Write((byte)(im != null ? 2 : 1));
     if (im != null)
     {
         bw.Write((short)im.AlphaBlend);
         bw.Write((byte)im.Alpha);
         bw.Write((byte)im.Red);
         bw.Write((byte)im.Green);
         bw.Write((byte)im.Blue);
         bw.Write((short)im.ScaleX);
         bw.Write((short)im.ScaleY);
         bw.Write((short)im.SkewX);
         bw.Write((short)im.SkewY);
         bw.Write((short)im.Rotation);
     }
 }
        private static ImageManipulation ReadIM(BinaryReader br)
        {
            var flag = br.ReadByte();

            if (flag != 2)
            {
                return(null);
            }

            var ret = new ImageManipulation();

            ret.AlphaBlend = br.ReadInt16();
            ret.Alpha      = br.ReadByte();
            ret.Red        = br.ReadByte();
            ret.Green      = br.ReadByte();
            ret.Blue       = br.ReadByte();
            ret.ScaleX     = br.ReadInt16();
            ret.ScaleY     = br.ReadInt16();
            ret.SkewX      = br.ReadInt16();
            ret.SkewY      = br.ReadInt16();
            ret.Rotation   = br.ReadInt16();

            return(ret);
        }