コード例 #1
0
        public virtual void Save(Stream outputStream, PaginationSettings.FormatEncoding outputFormat)
        {
            Bitmap bitmap = null;
            bool   flag   = true;

            try
            {
                bitmap = System.Drawing.Image.FromHbitmap(this.m_hBitmap.Handle);
                switch (outputFormat)
                {
                case PaginationSettings.FormatEncoding.BMP:
                    bitmap.Save(outputStream, ImageFormat.Bmp);
                    break;

                case PaginationSettings.FormatEncoding.GIF:
                    bitmap.Save(outputStream, ImageFormat.Gif);
                    break;

                case PaginationSettings.FormatEncoding.JPEG:
                    bitmap.Save(outputStream, ImageFormat.Jpeg);
                    break;

                case PaginationSettings.FormatEncoding.PNG:
                    bitmap.Save(outputStream, ImageFormat.Png);
                    break;

                case PaginationSettings.FormatEncoding.TIFF:
                    if (this.m_firstImage == null)
                    {
                        this.m_firstImage = bitmap;
                        flag = false;
                        this.m_encoderParameters          = new EncoderParameters(2);
                        this.m_encoderParameters.Param[0] = new EncoderParameter(Encoder.SaveFlag, 18L);
                        this.m_encoderParameters.Param[1] = new EncoderParameter(Encoder.ColorDepth, 24L);
                        this.m_firstImage.Save(outputStream, Graphics.GetEncoderInfo("image/tiff"), this.m_encoderParameters);
                        EncoderParameter encoderParameter = this.m_encoderParameters.Param[0];
                        this.m_encoderParameters.Param[0] = new EncoderParameter(Encoder.SaveFlag, 23L);
                        if (encoderParameter != null)
                        {
                            encoderParameter.Dispose();
                            encoderParameter = null;
                        }
                    }
                    else
                    {
                        this.m_firstImage.SaveAdd(bitmap, this.m_encoderParameters);
                    }
                    break;
                }
                outputStream.Flush();
            }
            finally
            {
                if (flag && bitmap != null)
                {
                    bitmap.Dispose();
                    bitmap = null;
                }
            }
        }
コード例 #2
0
 internal override void Save(Stream outputStream, PaginationSettings.FormatEncoding outputFormat)
 {
     if (m_metafile != null)
     {
         ExecuteSync(delegate
         {
             m_metafile.Dispose();
         });
         m_metafile = null;
     }
     outputStream.Flush();
     (outputStream as IRenderStream)?.Finish();
 }
コード例 #3
0
 public void EndReport(PaginationSettings.FormatEncoding outputFormat)
 {
     if (outputFormat == PaginationSettings.FormatEncoding.TIFF)
     {
         EncoderParameter encoderParameter = this.m_encoderParameters.Param[0];
         this.m_encoderParameters.Param[0] = new EncoderParameter(Encoder.SaveFlag, 20L);
         if (encoderParameter != null)
         {
             encoderParameter.Dispose();
             encoderParameter = null;
         }
         this.m_firstImage.SaveAdd(this.m_encoderParameters);
     }
 }
コード例 #4
0
        public override void Save(Stream outputStream, PaginationSettings.FormatEncoding outputFormat)
        {
            if (this.m_metafile != null)
            {
                this.ExecuteSync(delegate
                {
                    this.m_metafile.Dispose();
                });
                this.m_metafile = null;
            }
            outputStream.Flush();
            IRenderStream renderStream = outputStream as IRenderStream;

            if (renderStream != null)
            {
                renderStream.Finish();
            }
        }
コード例 #5
0
        internal void NewPage(Stream stream, PaginationSettings.FormatEncoding outputFormat, float pageWidth, float pageHeight, int dpiX, int dpiY)
        {
            if (m_graphicsBase != null)
            {
                ReleaseCachedHdc(releaseHdc: true);
                m_graphicsBase.Dispose();
                m_graphicsBase = null;
            }
            System.Drawing.Graphics graphics = CreateMetafileGraphics();
            IntPtr  hdc     = graphics.GetHdc();
            EmfType emfType = EmfType.EmfPlusOnly;

            if (outputFormat == PaginationSettings.FormatEncoding.EMF)
            {
                emfType = EmfType.EmfPlusDual;
            }
            try
            {
                RectangleF rect = CalculateMetafileRectangle(hdc, pageWidth, pageHeight, dpiX, dpiY);
                ExecuteSync(delegate
                {
                    m_metafile     = new Metafile(stream, hdc, rect, MetafileFrameUnit.GdiCompatible, emfType);
                    m_graphicsBase = System.Drawing.Graphics.FromImage(m_metafile);
                    Graphics.SetGraphicsProperties(m_graphicsBase);
                });
            }
            finally
            {
                if (hdc != IntPtr.Zero)
                {
                    graphics.ReleaseHdc(hdc);
                }
                if (graphics != null)
                {
                    graphics.Dispose();
                    graphics = null;
                }
            }
        }
コード例 #6
0
        public void NewPage(Stream stream, PaginationSettings.FormatEncoding outputFormat, RectangleF metafileRectangle, int dpiX, int dpiY)
        {
            if (base.m_graphicsBase != null)
            {
                this.ReleaseCachedHdc(true);
                base.m_graphicsBase.Dispose();
                base.m_graphicsBase = null;
            }
            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(base.m_imageBase);
            IntPtr  hdc     = graphics.GetHdc();
            EmfType emfType = EmfType.EmfPlusOnly;

            if (outputFormat == PaginationSettings.FormatEncoding.EMF)
            {
                emfType = EmfType.EmfPlusDual;
            }
            try
            {
                this.ExecuteSync(delegate
                {
                    this.m_metafile     = new Metafile(stream, hdc, metafileRectangle, MetafileFrameUnit.GdiCompatible, emfType);
                    base.m_graphicsBase = System.Drawing.Graphics.FromImage(this.m_metafile);
                    Graphics.SetGraphicsProperties(base.m_graphicsBase);
                });
            }
            finally
            {
                if (hdc != IntPtr.Zero)
                {
                    graphics.ReleaseHdc(hdc);
                }
                if (graphics != null)
                {
                    graphics.Dispose();
                    graphics = null;
                }
            }
        }