示例#1
0
        /// <summary>
        /// Gets an enhanced metafile image for the current GraphPane.
        /// </summary>
        /// <seealso cref="GetImage()"/>
        /// <seealso cref="GetImage(int,int,float)"/>
        /// <seealso cref="GetMetafile(int,int)"/>
        public Metafile GetMetafile()
        {
            Bitmap bm = new Bitmap( 1, 1 );
            using ( Graphics g = Graphics.FromImage( bm ) )
            {
                IntPtr hdc = g.GetHdc();
                Stream stream = new MemoryStream();
                Metafile metafile = new Metafile( stream, hdc, _rect,
                            MetafileFrameUnit.Pixel, EmfType.EmfOnly );

                using (IGraphics metafileGraphics = new GdiGraphics(Graphics.FromImage(metafile)))
                {
                    metafileGraphics.TranslateTransform( -_rect.Left, -_rect.Top );
                    metafileGraphics.PageUnit = GraphicsUnit.Pixel;
                    PointF P = new PointF( _rect.Width, _rect.Height );
                    PointF[] PA = new[] { P };
                    metafileGraphics.TransformPoints( CoordinateSpace.Page, CoordinateSpace.Device, PA );
                    //metafileGraphics.PageScale = 1f;

                    // output
                    Draw( metafileGraphics );

                    g.ReleaseHdc( hdc );
                    return metafile;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Build a <see cref="Bitmap"/> object containing the graphical rendering of
        /// all the <see cref="GraphPane"/> objects in this list.
        /// </summary>
        /// <value>A <see cref="Bitmap"/> object rendered with the current graph.</value>
        /// <seealso cref="GetImage(int,int,float)"/>
        /// <seealso cref="GetMetafile()"/>
        /// <seealso cref="GetMetafile(int,int)"/>
        public Bitmap GetImage( bool isAntiAlias )
        {
            Bitmap bitmap = new Bitmap( (int) _rect.Width, (int) _rect.Height );
            using (IGraphics bitmapGraphics = new GdiGraphics(Graphics.FromImage(bitmap)))
            {
                bitmapGraphics.TranslateTransform( -_rect.Left, -_rect.Top );
                Draw( bitmapGraphics );
            }

            return bitmap;
        }