Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the Bytescout.PDF.Image class from the specified existing image.
 /// </summary>
 /// <param name="image" href="http://msdn.microsoft.com/en-us/library/system.drawing.image.aspx">The System.Drawing.Image from which to create the new Bytescout.PDF.Image.</param>
 /// <param name="compression">The compression filter used for this image.</param>
 /// <param name="jpegQuality">The JPEG quality.</param>
 public Image(System.Drawing.Image image, ImageCompression compression, int jpegQuality)
     : this(image)
 {
     Compression = compression;
     if (compression == ImageCompression.DCT)
     {
         DCTDecoder.Encode(image, _dict.GetStream(), jpegQuality);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the Bytescout.PDF.Image class from the specified data stream.
 /// </summary>
 /// <param name="stream" href="http://msdn.microsoft.com/en-us/library/system.io.stream.aspx">The data stream used to load the image.</param>
 /// <param name="compression">The compression filter used for this image.</param>
 /// <param name="jpegQuality">The JPEG quality.</param>
 public Image(Stream stream, ImageCompression compression, int jpegQuality)
     : this(stream)
 {
     Compression = compression;
     if (compression == ImageCompression.DCT)
     {
         System.Drawing.Image image = System.Drawing.Image.FromStream(stream);
         DCTDecoder.Encode(image, _dict.GetStream(), jpegQuality);
         image.Dispose();
     }
 }
Exemplo n.º 3
0
        public void Decode()
        {
            Filter[] filters = getFilters();
            if (filters.Length == 0)
            {
                return;
            }

            _stream.Position = 0;
            try
            {
                for (int i = 0; i < filters.Length; ++i)
                {
                    switch (filters[i])
                    {
                    case Filter.ASCII85:
                        _stream = ASCII85Decoder.Decode(_stream);
                        break;

                    case Filter.ASCIIHex:
                        _stream = ASCIIHexDecoder.Decode(_stream);
                        break;

                    case Filter.RunLength:
                        _stream = RunLengthDecoder.Decode(_stream);
                        break;

                    case Filter.JPX:
                        _stream = JPXDecoder.Decode(_stream);
                        break;

                    case Filter.CCITTFax:
                        _stream = CCITTFaxDecoder.Decode(_stream, getDecodeParameters(i));
                        break;

                    case Filter.DCT:
                        _stream = DCTDecoder.Decode(_stream, getDecodeParameters(i));
                        break;

                    case Filter.Flate:
                        _stream = FlateDecoder.Decode(_stream, getDecodeParameters(i));
                        break;

                    case Filter.JBIG2:
                        _stream = JBIG2Decoder.Decode(_stream, getDecodeParameters(i));
                        break;

                    case Filter.LZW:
                        _stream = LZWDecoder.Decode(_stream, getDecodeParameters(i));
                        break;
                    }
                    _stream.Position = 0;
                }
            }
            catch
            {
                return;
            }

            _dictionary.RemoveItem("Filter");
            _dictionary.RemoveItem("DecodeParms");
        }