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
        private void createFromStream(Stream imageData, IDecompressDestination dst)
        {
            if (imageData == null)
            {
                throw new ArgumentNullException("imageData");
            }

            if (isCompressed(imageData))
            {
                m_compressedData = Utils.CopyStream(imageData);

                decompress(dst);
            }
            else
            {
                throw new NotImplementedException("JpegImage.createFromStream(Stream)");
            }
        }
Esempio n. 4
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. 5
0
 /// <summary>
 /// Creates <see cref="JpegImage"/> from stream with an arbitrary image data
 /// </summary>
 /// <param name="imageData">Stream containing bytes of image in
 /// arbitrary format (BMP, Jpeg, GIF, PNG, TIFF, e.t.c)</param>
 public JpegImage(Stream imageData, IDecompressDestination dst)
 {
     //new DecompressorToJpegImage(this)
     createFromStream(imageData, dst);
 }
Esempio n. 6
0
        private void decompress(IDecompressDestination dst)
        {
            Jpeg jpeg = new Jpeg();

            jpeg.Decompress(compressedData, dst);
        }