Esempio n. 1
0
        /// <summary>
        /// Decompresses JPEG image to any image described as ICompressDestination
        /// </summary>
        /// <param name="jpeg">Stream with JPEG data</param>
        /// <param name="destination">Stream for output of compressed JPEG</param>
        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();
        }
Esempio n. 2
0
        /// <summary>
        /// Decompresses JPEG image to any image described as ICompressDestination
        /// </summary>
        /// <param name="jpeg">Stream with JPEG data</param>
        /// <param name="destination">Stream for output of compressed JPEG</param>
        public void Decompress(Stream jpeg, IDecompressDestination destination)
        {
            if (jpeg is null)
            {
                throw new ArgumentNullException(nameof(jpeg));
            }

            if (destination is null)
            {
                throw new ArgumentNullException(nameof(destination));
            }

            beforeDecompress(jpeg);

            // Start decompression
            ClassicDecompressor.JpegStartDecompress();

            var parameters = getImageParametersFromDecompressor();

            destination.SetImageAttributes(parameters);
            destination.BeginWrite();

            /* Process data */
            while (ClassicDecompressor.Output_scanline < ClassicDecompressor.Output_height)
            {
                var row = JpegCommonStruct.AllocJpegSamples(ClassicDecompressor.Output_width * ClassicDecompressor.Output_components, 1);
                ClassicDecompressor.JpegReadScanlines(row, 1);
                destination.ProcessPixelsRow(row[0]);
            }

            destination.EndWrite();

            // Finish decompression and release memory.
            ClassicDecompressor.JpegFinishDecompress();
        }
Esempio n. 3
0
		/// <summary>
		/// Decompresses JPEG image to any image described as ICompressDestination
		/// </summary>
		/// <param name="jpeg">Stream with JPEG data</param>
		/// <param name="destination">Stream for output of compressed JPEG</param>
		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();
		}