Пример #1
0
        public Color[] SetData(Color[] px, byte[] zpx, System.Drawing.Rectangle rect)
        {
            PixelCache  = null; //can't exactly dispose this.. it's likely still in use!
            ZCache      = null;
            PixelData   = px;
            ZBufferData = zpx;
            Position    = new Vector2(rect.X, rect.Y);

            Width  = rect.Width;
            Height = rect.Height;
            Flags  = 7;
            TransparentColorIndex = 255;

            var colors = SPR2FrameEncoder.QuantizeFrame(this, out PalData);

            var palt = new Color[256];
            int i    = 0;

            foreach (var c in colors)
            {
                palt[i++] = new Color(c.R, c.G, c.B, 255);
            }

            return(palt);
        }
Пример #2
0
        public void Write(IoWriter io)
        {
            using (var sprStream = new MemoryStream())
            {
                var sprIO = IoWriter.FromStream(sprStream, ByteOrder.LITTLE_ENDIAN);
                sprIO.WriteUInt16((ushort)Width);
                sprIO.WriteUInt16((ushort)Height);
                sprIO.WriteUInt32(Flags);
                sprIO.WriteUInt16(PaletteID);
                sprIO.WriteUInt16(TransparentColorIndex);
                sprIO.WriteUInt16((ushort)Position.Y);
                sprIO.WriteUInt16((ushort)Position.X);
                SPR2FrameEncoder.WriteFrame(this, sprIO);

                var data = sprStream.ToArray();
                io.WriteUInt32(1001);
                io.WriteUInt32((uint)data.Length + 8);
                io.WriteBytes(data);
            }
        }