Exemplo n.º 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();
            }
        }
Exemplo n.º 2
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))
            {
                JpegParser parser = new JpegParser(m_bitmaps);
                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();
            }
        }