Esempio n. 1
0
        private void Decompress(ref BinaryReader binaryReader)
        {
            var bitDepth = ImageCompression.ColorModel.RGB.ColorDepth.TwentyFour;

            // Default to RGB for now
            System.Type colorModel = typeof(ImageCompression.ColorModel.RGB);

            // Set the bit depth in use
            if (this.compressionFlags.FlagIsSet((byte)CompressionFlags.EightBit))
            {
                bitDepth = ImageCompression.ColorModel.RGB.ColorDepth.Eight;
            }
            else if (this.compressionFlags.FlagIsSet((byte)CompressionFlags.FifteenBit))
            {
                bitDepth = ImageCompression.ColorModel.RGB.ColorDepth.Fifteen;
            }
            else if (this.compressionFlags.FlagIsSet((byte)CompressionFlags.EighteenBit))
            {
                bitDepth = ImageCompression.ColorModel.RGB.ColorDepth.Eighteen;
            }
            else if (this.compressionFlags.FlagIsSet((byte)CompressionFlags.TwentyFourBit))
            {
                bitDepth = ImageCompression.ColorModel.RGB.ColorDepth.TwentyFour;
            }

            var decodedData = new List <ImageCompression.Interfaces.IEncodable>();

            // If LZ77 is enabled
            if ((this.compressionFlags & (byte)CompressionFlags.LZ77) == (byte)CompressionFlags.LZ77)
            {
                // Decode LZ77
                var decodedLZ77 = LZ77.DecodeBinaryStream(ref binaryReader, bitDepth);

                // If run length is enabled
                if ((this.compressionFlags & (byte)CompressionFlags.RunLength) == (byte)CompressionFlags.RunLength)
                {
                    var fullDecodedLZ77 = LZ77.Decode <RunLengthStore <ImageCompression.ColorModel.RGB> >(decodedLZ77).ToList();
                }
                else
                {
                    var fullDecodedLZ77 = LZ77.Decode <ImageCompression.ColorModel.RGB>(decodedLZ77).ToList();

                    if (bitDepth != ImageCompression.ColorModel.RGB.ColorDepth.TwentyFour)
                    {
                        fullDecodedLZ77 = fullDecodedLZ77.ConvertAll(new Converter <RGB, RGB>(x => x.ToDepth(RGB.ColorDepth.TwentyFour)));
                    }
                    this.saveTempBitmap(fullDecodedLZ77, width, height);
                }
            }

            // If run length is enabled
            if ((this.compressionFlags & (byte)CompressionFlags.RunLength) == (byte)CompressionFlags.RunLength)
            {
            }
            else
            {
            }

            // All decoded
        }