コード例 #1
0
        public void UnpackLayerImage(byte[] packedLayerImage)
        {
            Clear();
            int x           = 0;
            int y           = 0;
            int imageLength = packedLayerImage.Length;

            for (int i = 0; i < imageLength; i++)
            {
                byte rle       = packedLayerImage[i];
                byte colorCode = (byte)((rle & 0x60) >> 5);

                bool extended = (rle & 0x80) == 0x80;
                int  length   = rle & 0x1F;
                if (extended)
                {
                    i++;
                    length = (length << 8) | packedLayerImage[i] & 0x00ff;
                }

                ArraysEmulation.Fill(iArray[y], x, x + length, colorCode);

                if (colorCode == SUPPORTED)
                {
                    pixels[y] += length;
                }
                else if (colorCode == CONNECTED)
                {
                    pixels[y] += length;
                }
                else if (colorCode == ISLAND)
                {
                    rowIslands[y] += length;
                    islandCount   += length;
                    pixels[y]     += length;
                }

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