예제 #1
0
        private static void DecodeMajMinH(byte[] buffer, int width, int height, int stripX, byte[] source, int sourcePos, int indexSize, bool transparent)
        {
            int         runlength    = 0;
            LEBitStream sourceStream = new LEBitStream(source, sourcePos);
            byte        color        = sourceStream.GetByte();
            int         x            = stripX;
            int         y            = 0;

            while (y < height)
            {
                while (x < stripX + 8)
                {
                    buffer[y * width + x] = color;
                    x++;
                    if (runlength > 0)
                    {
                        runlength--;
                        continue;
                    }

                    if (sourceStream.GetBit() == 0) // 0
                    {
                    }
                    else if (sourceStream.GetBit() == 0) // 10
                    {
                        color = (byte)(sourceStream.GetBits(indexSize));
                    }
                    else // 11
                    {
                        int code = sourceStream.GetBits(3) - 4;
                        if (code != 0)
                        {
                            color = (byte)(color + code);
                        }
                        else
                        {
                            runlength = sourceStream.GetBits(8) - 1;
                        }
                    }
                }
                x = stripX;
                y++;
            }
        }
예제 #2
0
        // Predecessor of ZigZag codec
        // Vertical pixel order
        private static void DecodeOldZigZagV(byte[] buffer, int width, int height, int stripX, byte[] source, int sourcePos, bool transparent)
        {
            int x   = stripX;
            int y   = 0;
            int sub = 1;

            byte color = source[sourcePos++];

            LEBitStream sourceStream = new LEBitStream(source, sourcePos);

            while (x < stripX + 8)
            {
                while (y < height)
                {
                    buffer[y * width + x] = color;
                    y++;

                    if (sourceStream.GetBit() == 0) // 0
                    {
                        // do nothing (draw pixel, same color)
                    }
                    else if (sourceStream.GetBit() == 0) // 10
                    {
                        sub   = -sub;
                        color = (byte)(color - sub);
                    }
                    else if (sourceStream.GetBit() == 0) // 110
                    {
                        color = (byte)(color - sub);
                    }
                    else // 111
                    {
                        sub   = 1;
                        color = (byte)sourceStream.GetBits(8);
                    }
                }
                y = 0;
                x++;
            }
        }
예제 #3
0
        private static void DecodeZigzagH(byte[] buffer, int width, int height, int stripX, byte[] source, int sourcePos, int indexSize, bool transparent)
        {
            int         sub          = 1;
            LEBitStream sourceStream = new LEBitStream(source, sourcePos);
            byte        color        = sourceStream.GetByte();
            int         x            = stripX;
            int         y            = 0;

            while (y < height)
            {
                while (x < stripX + 8)
                {
                    buffer[y * width + x] = color;

                    if (sourceStream.GetBit() == 0) // 0
                    {
                        // Do nothing (draw pixel, same color)
                    }
                    else if (sourceStream.GetBit() == 0) // 10
                    {
                        color = (byte)(sourceStream.GetBits(indexSize));
                        sub   = 1;
                    }
                    else if (sourceStream.GetBit() == 0) // 110
                    {
                        color = (byte)(color - sub);
                    }
                    else // 111
                    {
                        sub   = -sub;
                        color = (byte)(color - sub);
                    }
                    x++;
                }
                x = stripX;
                y++;
            }
        }