Пример #1
0
        private static void writeLayerBlock(Layer l, Stream stream)
        {
            List<byte> bytes = new List<byte>();

            bytes.AddRange(new byte[] { 0, 0 });

            bytes.Add(l.type);

            byte[] name = Encoding.UTF8.GetBytes(l.name);

            bytes.Add((byte)(name.Length - 1));
            //(the - 1 allows 256 characters instead of just 255, by replacing 1 with 0, 2 with 1 and so forth)

            bytes.AddRange(name);

            bytes.InsertRange(0, BitConverter.GetBytes(bytes.Count));

            stream.Write(bytes.ToArray(), 0, bytes.Count);

            if (l.type == 4)
                writeCustomFigBlock(l, stream);

            if (l.type == 7)
                writeImageBlock(l, stream);

            for (int x = 0;x < l.keyFrames.Count;x++)
                writeFrameBlock(l.keyFrames[x], stream);

            List<byte> b2 = new List<byte>();
            b2.AddRange(BitConverter.GetBytes((int)3));
            b2.AddRange(BitConverter.GetBytes((ushort)1));
            b2.Add(0);

            stream.Write(b2.ToArray(), 0, 7);
        }
Пример #2
0
        private static void writeCustomFigBlock(Layer l, Stream s)
        {
            List<byte> bytes = new List<byte>();

            bytes.AddRange(BitConverter.GetBytes((ushort)7));

            StickCustom cust = new StickCustom();
            cust.Joints = l.keyFrames[0].Joints;

            CustomFigSaver.saveFigure(bytes, cust);

            bytes.InsertRange(0, BitConverter.GetBytes(bytes.Count));

            s.Write(bytes.ToArray(), 0, bytes.Count);
        }
Пример #3
0
        private static void writeImageBlock(Layer l, Stream s)
        {
            List<byte> bytes = new List<byte>();

            bytes.AddRange(BitConverter.GetBytes((ushort)8));

            Bitmap b = ((ImageLayer)l).img;
            ImageConverter converter = new ImageConverter();
            bytes.AddRange((byte[])converter.ConvertTo(b, typeof(byte[])));

            bytes.InsertRange(0, BitConverter.GetBytes(bytes.Count));

            s.Write(bytes.ToArray(), 0, bytes.Count);
        }