BitMiracle.LibJpeg.Jpeg.Decompress C# (CSharp) Method

Decompress() public method

Decompresses JPEG image to any image described as ICompressDestination
public Decompress ( Stream jpeg, IDecompressDestination destination ) : void
jpeg Stream Stream with JPEG data
destination IDecompressDestination Stream for output of compressed JPEG
return void
        public void Decompress(Stream jpeg, IDecompressDestination destination)
        {
            if (jpeg == null)
                throw new ArgumentNullException("jpeg");

            if (destination == null)
                throw new ArgumentNullException("destination");

            beforeDecompress(jpeg);

            // Start decompression
            m_decompressor.jpeg_start_decompress();

            LoadedImageAttributes parameters = getImageParametersFromDecompressor();
            destination.SetImageAttributes(parameters);
            destination.BeginWrite();

            /* Process data */
            while (m_decompressor.Output_scanline < m_decompressor.Output_height)
            {
                byte[][] row = jpeg_common_struct.AllocJpegSamples(m_decompressor.Output_width * m_decompressor.Output_components, 1);
                m_decompressor.jpeg_read_scanlines(row, 1);
                destination.ProcessPixelsRow(row[0]);
            }

            destination.EndWrite();

            // Finish decompression and release memory.
            m_decompressor.jpeg_finish_decompress();
        }

Usage Example

コード例 #1
0
        private void fillDecompressedData()
        {
            Debug.Assert(m_decompressedData == null);

            m_decompressedData = new MemoryStream();
            BitmapDestination dest = new BitmapDestination(m_decompressedData);

            Jpeg jpeg = new Jpeg();

            jpeg.Decompress(compressedData, dest);
        }
All Usage Examples Of BitMiracle.LibJpeg.Jpeg::Decompress