Exemple #1
0
        /// <summary>
        ///     Extracts the raw data from the image into a byte array suitable
        ///     for including in the PDF document.  The image is always extracted
        ///     as a 24-bit RGB image, regardless of it's original colour space
        ///     and colour depth.
        /// </summary>
        /// <param name="bitmap">The <see cref="Bitmap"/> from which the data is extracted</param>
        /// <returns>A byte array containing the raw 24-bit RGB data</returns>
        private void ExtractImage(Bitmap bitmap)
        {
            // This should be a factory when we handle more image types
            if (bitmap.RawFormat.Equals(ImageFormat.Jpeg))
            {
                using (JpegParser parser = new JpegParser(m_bitmaps))
                {
                    using (JpegInfo info = parser.Parse())
                    {
                        m_bitsPerPixel = info.BitsPerSample;
                        m_colorSpace   = new ColorSpace(info.ColourSpace);
                        width          = info.Width;
                        height         = info.Height;
                    }
                }

                // A "no-op" filter since the JPEG data is already compressed
                filter = new DctFilter();
            }
            else
            {
                ExtractOtherImageBits(bitmap);

                // Performs zip compression
                filter = new FlateFilter();
            }
        }
 public void Dispose()
 {
     this.headerInfo     = null;
     this.iccProfileData = null;
     if (ms != null)
     {
         this.ms.Dispose();
     }
     ms = null;
     this.headerInfo = null;
 }
 /// <summary>
 ///     Class constructor.
 /// </summary>
 /// <param name="data"></param>
 public JpegParser(byte[] data)
 {
     this.ms         = new MemoryStream(data);
     this.headerInfo = new JpegInfo();
 }
Exemple #4
0
 /// <summary>
 ///     Class constructor.
 /// </summary>
 /// <param name="data"></param>
 public JpegParser(byte[] data)
 {
     this.ms = new MemoryStream(data);
     this.headerInfo = new JpegInfo();
 }