otitemeditor.Sprite.getRGBData C# (CSharp) Method

getRGBData() public method

public getRGBData ( byte transparentColor ) : byte[]
transparentColor byte
return byte[]
        public byte[] getRGBData(byte transparentColor)
        {
            byte[] rgb32x32x3 = new byte[32 * 32 * 3];
            UInt32 bytes = 0;
            UInt32 x = 0;
            UInt32 y = 0;
            Int32 chunkSize;

            while (bytes < size)
            {
                chunkSize = dump[bytes] | dump[bytes + 1] << 8;
                bytes += 2;

                for (int i = 0; i < chunkSize; ++i)
                {
                    // Transparent pixel
                    rgb32x32x3[96 * y + x * 3 + 0] = transparentColor;
                    rgb32x32x3[96 * y + x * 3 + 1] = transparentColor;
                    rgb32x32x3[96 * y + x * 3 + 2] = transparentColor;
                    x++;
                    if (x >= 32)
                    {
                        x = 0;
                        ++y;
                    }
                }

                if (bytes >= size) break; // We're done
                // Now comes a pixel chunk, read it!
                chunkSize = dump[bytes] | dump[bytes + 1] << 8;
                bytes += 2;
                for (int i = 0; i < chunkSize; ++i)
                {
                    byte red = dump[bytes + 0];
                    byte green = dump[bytes + 1];
                    byte blue = dump[bytes + 2];
                    rgb32x32x3[96 * y + x * 3 + 0] = red;
                    rgb32x32x3[96 * y + x * 3 + 1] = green;
                    rgb32x32x3[96 * y + x * 3 + 2] = blue;

                    bytes += 3;

                    x++;
                    if (x >= 32)
                    {
                        x = 0;
                        ++y;
                    }
                }
            }

            // Fill up any trailing pixels
            while (y < 32 && x < 32)
            {
                rgb32x32x3[96 * y + x * 3 + 0] = transparentColor;
                rgb32x32x3[96 * y + x * 3 + 1] = transparentColor;
                rgb32x32x3[96 * y + x * 3 + 2] = transparentColor;
                x++;
                if (x >= 32)
                {
                    x = 0;
                    ++y;
                }
            }

            return rgb32x32x3;
        }

Same methods

Sprite::getRGBData ( ) : byte[]