Пример #1
0
        private byte[] getImageColorType3BitDepth8()
        {
            int num  = 0;
            int num2 = 0;

            byte[] array = null;
            if (this.alphaForPalette != null)
            {
                array = new byte[this.w * this.h];
            }
            byte[] array2 = new byte[3 * (this.inflated.Length - this.h)];
            int    num3   = this.w + 1;

            for (int i = 0; i < this.inflated.Length; i++)
            {
                if (i % num3 != 0)
                {
                    int num4 = (int)(this.inflated[i] & 255);
                    array2[num++] = this.rgb[3 * num4];
                    array2[num++] = this.rgb[3 * num4 + 1];
                    array2[num++] = this.rgb[3 * num4 + 2];
                    if (this.alphaForPalette != null)
                    {
                        array[num2++] = this.alphaForPalette[num4];
                    }
                }
            }
            if (this.alphaForPalette != null)
            {
                Compressor compressor = new Compressor(array);
                this.deflatedAlpha = compressor.GetCompressedData();
            }
            return(array2);
        }
Пример #2
0
        private byte[] getImageColorType6BitDepth8()
        {
            int num = 0;

            byte[] array  = new byte[4 * this.w * this.h];
            byte   filter = 0;
            int    num2   = 4 * this.w;

            for (int i = 0; i < this.inflated.Length; i++)
            {
                if (i % (num2 + 1) == 0)
                {
                    filter = this.inflated[i];
                }
                else
                {
                    array[num] = this.inflated[i];
                    int a = 0;
                    int b = 0;
                    int c = 0;
                    if (num % num2 >= 4)
                    {
                        a = (int)(array[num - 4] & 255);
                    }
                    if (num >= num2)
                    {
                        b = (int)(array[num - num2] & 255);
                    }
                    if (num % num2 >= 4 && num >= num2)
                    {
                        c = (int)(array[num - (num2 + 4)] & 255);
                    }
                    this.applyFilters(filter, array, num, a, b, c);
                    num++;
                }
            }
            byte[] array2 = new byte[3 * this.w * this.h];
            byte[] array3 = new byte[this.w * this.h];
            int    num3   = 0;
            int    num4   = 0;

            for (int j = 0; j < array.Length; j += 4)
            {
                array2[num3]     = array[j];
                array2[num3 + 1] = array[j + 1];
                array2[num3 + 2] = array[j + 2];
                array3[num4]     = array[j + 3];
                num3            += 3;
                num4++;
            }
            Compressor compressor = new Compressor(array3);

            this.deflatedAlpha = compressor.GetCompressedData();
            return(array2);
        }
Пример #3
0
        // Indexed Image with Bit Depth == 8
        private byte[] getImageColorType3BitDepth8()
        {
            int j = 0;
            int n = 0;

            byte[] alpha = null;
            if (alphaForPalette != null)
            {
                alpha = new byte[this.w * this.h];
            }

            byte[] image          = new byte[3 * (inflated.Length - this.h)];
            int    scanLineLength = this.w + 1;

            for (int i = 0; i < inflated.Length; i++)
            {
                if (i % scanLineLength == 0)
                {
                    // Skip the filter byte
                    continue;
                }

                int k = ((int)inflated[i] & 0x000000ff);
                image[j++] = rgb[3 * k];
                image[j++] = rgb[3 * k + 1];
                image[j++] = rgb[3 * k + 2];

                if (alphaForPalette != null)
                {
                    alpha[n++] = alphaForPalette[k];
                }
            }

            if (alphaForPalette != null)
            {
                Compressor compressor = new Compressor(alpha);
                deflatedAlpha = compressor.GetCompressedData();
            }

            return(image);
        }
Пример #4
0
        // Truecolor Image with Alpha Transparency
        private byte[] getImageColorType6BitDepth8()
        {
            int j = 0;
            byte[] image = new byte[4 * this.w * this.h];

            byte filter = 0x00;
            int scanLineLength = 4 * this.w;

            for (int i = 0; i < inflated.Length; i++) {
            if (i % ( scanLineLength + 1) == 0) {
                filter = inflated[i];
                continue;
            }

            image[j] = inflated[i];

            int a = 0;
            int b = 0;
            int c = 0;

            if (j % scanLineLength >= 4 ) {
                a = (image[j - 4] & 0x000000ff);
            }
            if (j >= scanLineLength ) {
                b = (image[j - scanLineLength] & 0x000000ff );
            }
            if (j % scanLineLength >= 4 && j >= scanLineLength) {
                c = (image[j - (scanLineLength + 4 )] & 0x000000ff);
            }

            applyFilters(filter, image, j, a, b, c);
            j++;
            }

            byte[] idata = new byte[ 3 * this.w * this.h ]; // Image data
            byte[] alpha = new byte[this.w * this.h];       // Alpha values

            int k = 0;
            int n = 0;
            for (int i = 0; i < image.Length; i += 4) {
            idata[k]     = image[i];
            idata[k + 1] = image[i + 1];
            idata[k + 2] = image[i + 2];
            alpha[n]     = image[i + 3];

            k += 3;
            n += 1;
            }

            Compressor compressor = new Compressor(alpha);
            deflatedAlpha = compressor.GetCompressedData();

            return idata;
        }
Пример #5
0
        // Indexed Image with Bit Depth == 8
        private byte[] getImageColorType3BitDepth8()
        {
            int j = 0;
            int n = 0;

            byte[] alpha = null;
            if (alphaForPalette != null) {
            alpha = new byte[this.w * this.h];
            }

            byte[] image = new byte[3*(inflated.Length - this.h)];
            int scanLineLength = this.w + 1;
            for (int i = 0; i < inflated.Length; i++) {
            if (i % scanLineLength == 0) {
                // Skip the filter byte
                continue;
            }

            int k = ((int) inflated[i] & 0x000000ff);
            image[j++] = rgb[3*k];
            image[j++] = rgb[3*k + 1];
            image[j++] = rgb[3*k + 2];

            if (alphaForPalette != null) {
                alpha[n++] = alphaForPalette[k];
            }
            }

            if (alphaForPalette != null) {
            Compressor compressor = new Compressor(alpha);
            deflatedAlpha = compressor.GetCompressedData();
            }

            return image;
        }
Пример #6
0
 private byte[] DeflateReconstructedData()
 {
     Compressor compressor = new Compressor(image);
     return compressor.GetCompressedData();
 }
Пример #7
0
        private byte[] DeflateReconstructedData()
        {
            Compressor compressor = new Compressor(image);

            return(compressor.GetCompressedData());
        }
Пример #8
0
        // Truecolor Image with Alpha Transparency
        private byte[] getImageColorType6BitDepth8()
        {
            int j = 0;

            byte[] image = new byte[4 * this.w * this.h];

            byte filter         = 0x00;
            int  scanLineLength = 4 * this.w;

            for (int i = 0; i < inflated.Length; i++)
            {
                if (i % (scanLineLength + 1) == 0)
                {
                    filter = inflated[i];
                    continue;
                }

                image[j] = inflated[i];

                int a = 0;
                int b = 0;
                int c = 0;

                if (j % scanLineLength >= 4)
                {
                    a = (image[j - 4] & 0x000000ff);
                }
                if (j >= scanLineLength)
                {
                    b = (image[j - scanLineLength] & 0x000000ff);
                }
                if (j % scanLineLength >= 4 && j >= scanLineLength)
                {
                    c = (image[j - (scanLineLength + 4)] & 0x000000ff);
                }

                applyFilters(filter, image, j, a, b, c);
                j++;
            }

            byte[] idata = new byte[3 * this.w * this.h]; // Image data
            byte[] alpha = new byte[this.w * this.h];     // Alpha values

            int k = 0;
            int n = 0;

            for (int i = 0; i < image.Length; i += 4)
            {
                idata[k]     = image[i];
                idata[k + 1] = image[i + 1];
                idata[k + 2] = image[i + 2];
                alpha[n]     = image[i + 3];

                k += 3;
                n += 1;
            }

            Compressor compressor = new Compressor(alpha);

            deflatedAlpha = compressor.GetCompressedData();

            return(idata);
        }