Compress() public static method

public static Compress ( byte data ) : byte[]
data byte
return byte[]
Exemplo n.º 1
0
        /// <summary>
        /// Returns the tiles of this Tileset (empty 0th tile excluded) written sequentially in a byte array
        /// </summary>
        public byte[] ToBytes(bool compressed)
        {
            byte[] result = new byte[Count * GBA.Tile.LENGTH];
            int    index  = 0;

            for (int i = 0; i < Count; i++)
            {
                Array.Copy(Sheet[i].Bytes, 0, result, index, Sheet[i].Bytes.Length);
                index += Sheet[i].Bytes.Length;
            }

            return(compressed ? LZ77.Compress(result) : result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns a byte array of this GBA.Palette.
        /// </summary>
        public Byte[] ToBytes(bool compressed)
        {
            byte[] result = new byte[Count * 2];
            byte[] color;
            int    index = 0;

            for (int i = 0; i < Count; i++)
            {
                color             = Colors[i].ToBytes(true);
                result[index]     = color[0];
                result[index + 1] = color[1];
                index            += 2;
            }
            return(compressed ? LZ77.Compress(result) : result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns this TSA array as a byte array, LZ77 compressed or not
        /// </summary>
        public Byte[] ToBytes(bool compressed, bool flipRows)
        {
            byte[] result = new byte[Tiles.Length * 2];
            for (int i = 0; i < Tiles.Length; i++)
            {
                result[i * 2]     = (byte)(Tiles[i].Value & 0x00FF);
                result[i * 2 + 1] = (byte)((Tiles[i].Value & 0xFF00) >> 8);
            }

            if (flipRows)
            {
                result = FlipRows(Width, Height, result);
            }

            return(compressed ? LZ77.Compress(result) : result);
        }