示例#1
0
        private void button4_Click(object sender, EventArgs e)
        {
            //----------------------
            //1. test gdi+ font path
            char  testChar = 'b';
            float fontSize = 20;

            using (Graphics g = this.pictureBox1.CreateGraphics())
            {
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                g.Clear(System.Drawing.Color.White);
                //convert Agg vxs to bitmap
                int bmpW = 500;
                int bmpH = 500;
                using (Bitmap bufferBmp = new Bitmap(bmpW, bmpH))
                {
                    ActualImage      actualImage = new ActualImage(bmpW, bmpH);
                    AggRenderSurface gfx         = new AggRenderSurface(actualImage);
                    var vxs = new PixelFarm.Drawing.VertexStore();
                    //vxs.AddMoveTo(0, 0);
                    ////vxs.AddP3c(100, 0);
                    ////vxs.AddP3c(100,150);
                    ////vxs.AddLineTo(0,0);
                    //vxs.AddLineTo(0, 0);
                    //vxs.AddP3c(100, 0);
                    ////vxs.AddLineTo(100, 0);
                    ////vxs.AddLineTo(100, 150);
                    //vxs.AddP3c(100, 150);
                    //vxs.AddLineTo(0, 150);
                    //vxs.AddCloseFigure();

                    //PixelFarm.Agg.VertexSource.CurveFlattener cflat = new PixelFarm.Agg.VertexSource.CurveFlattener();
                    //vxs = cflat.MakeVxs(vxs);

                    gfx.Render(vxs, PixelFarm.Drawing.Color.Black);
                    //test subpixel rendering


                    vxs = vxs.TranslateToNewVxs(15, 0, new PixelFarm.Drawing.VertexStore());
                    gfx.UseSubPixelRendering = true;
                    gfx.Render(vxs, PixelFarm.Drawing.Color.Black);
                    PixelFarm.Agg.Imaging.BitmapHelper.CopyToGdiPlusBitmapSameSize(
                        actualImage, //src from actual img buffer
                        bufferBmp    //dest to buffer bmp
                        );
                    //-----------------------------------------
                    bufferBmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
                    g.DrawImage(bufferBmp, new System.Drawing.Point(0, 30));
                }
            }
        }