Ejemplo n.º 1
0
            public SpriteDosTransparent(Buffer data, ColorDos[] palette, byte colorOffset = 0)
                : base(data)
            {
                MutableBuffer result = new MutableBuffer(Endian.Endianess.Big);

                while (data.Readable())
                {
                    uint drop = data.Pop <byte>();
                    result.Push(0x00000000u, drop);

                    uint fill = data.Pop <byte>();

                    for (uint i = 0; i < fill; ++i)
                    {
                        uint     palIndex = (uint)(data.Pop <byte>() + colorOffset);
                        ColorDos color    = palette[palIndex];
                        result.Push <byte>(color.B);  // Blue
                        result.Push <byte>(color.G);  // Green
                        result.Push <byte>(color.R);  // Red
                        result.Push <byte>(0xFF);     // Alpha
                    }
                }

                this.data = result.Unfix();
            }
Ejemplo n.º 2
0
            public SpriteDosSolid(Buffer data, ColorDos[] palette)
                : base(data)
            {
                uint size = data.Size;

                if (size != (width * height + 10))
                {
                    throw new ExceptionFreeserf(ErrorSystemType.Data, "Failed to extract DOS solid sprite");
                }

                MutableBuffer result = new MutableBuffer(Endian.Endianess.Big);

                while (data.Readable())
                {
                    ColorDos color = palette[data.Pop <byte>()];
                    result.Push <byte>(color.B);  // Blue
                    result.Push <byte>(color.G);  // Green
                    result.Push <byte>(color.R);  // Red
                    result.Push <byte>(0xff);     // Alpha
                }

                this.data = result.Unfix();
            }
Ejemplo n.º 3
0
        ColorDos[] GetDosPalette(uint index)
        {
            Buffer data = GetObject(index);

            if (data == null || (data.Size != 3 * 256)) // sizeof(ColorDos) = 3
            {
                return(null);
            }

            ColorDos[] palette = new ColorDos[256];
            var        array   = data.ReinterpretAsArray(256 * 3);

            for (int i = 0; i < 256; ++i)
            {
                palette[i] = new ColorDos()
                {
                    R = array[i * 3 + 0],
                    G = array[i * 3 + 1],
                    B = array[i * 3 + 2]
                };
            }

            return(palette);
        }
Ejemplo n.º 4
0
            public SpriteDosOverlay(Buffer data, ColorDos[] palette, byte value)
                : base(data)
            {
                MutableBuffer result = new MutableBuffer(Endian.Endianess.Big);

                while (data.Readable())
                {
                    uint drop = data.Pop <byte>();
                    result.Push(0x00000000u, drop);

                    uint fill = data.Pop <byte>();

                    for (uint i = 0; i < fill; ++i)
                    {
                        ColorDos color = palette[value];
                        result.Push <byte>(color.B);  // Blue
                        result.Push <byte>(color.G);  // Green
                        result.Push <byte>(color.R);  // Red
                        result.Push <byte>(value);    // Alpha
                    }
                }

                this.data = result.Unfix();
            }