Ejemplo n.º 1
0
        void SoftAggControl_Load(object sender, EventArgs e)
        {
            if (_useGdiPlusOutput)
            {
                // This example assumes the existence of a form called Form1.
                // Gets a reference to the current BufferedGraphicsContext
                //BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current;
                //_myBuffGfx = currentContext.Allocate(this.CreateGraphics(),
                //   this.DisplayRectangle);

                // Creates a BufferedGraphics instance associated with Form1, and with
                // dimensions the same size as the drawing surface of Form1.
                thisGfx       = this.CreateGraphics(); //for render to output
                bufferBmpRect = this.DisplayRectangle;
                bufferBmp     = new Bitmap(bufferBmpRect.Width, bufferBmpRect.Height);
                var gdiPlusCanvasPainter = new PixelFarm.Drawing.WinGdi.GdiPlusCanvasPainter(bufferBmp);
                gdiPlusCanvasPainter.SmoothingMode = _gdiAntiAlias ? PixelFarm.Drawing.SmoothingMode.AntiAlias : PixelFarm.Drawing.SmoothingMode.HighSpeed;
                painter             = gdiPlusCanvasPainter;
                painter.CurrentFont = new PixelFarm.Drawing.RequestFont("tahoma", 10);
            }
            else
            {
                ImageGraphics2D  imgGfx2d   = Initialize(myWidth, myHeight, 32);
                AggCanvasPainter aggPainter = new AggCanvasPainter(imgGfx2d);
                //set text printer for agg canvas painter
                aggPainter.CurrentFont = new PixelFarm.Drawing.RequestFont("tahoma", 10);
                VxsTextPrinter textPrinter = new VxsTextPrinter(aggPainter);
                aggPainter.TextPrinter = textPrinter;

                painter = aggPainter;
            }


            painter.Clear(PixelFarm.Drawing.Color.White);
        }
Ejemplo n.º 2
0
        public FloodFillDemo()
        {
            BackgroundColor = Color.White;
            imageToFillOn   = new ActualImage(400, 300, PixelFormat.ARGB32);
            ImageGraphics2D imageToFillGraphics = Graphics2D.CreateFromImage(imageToFillOn);

            imageToFillGraphics.Clear(Color.White);
            //imageToFillGraphics.DrawString("Click to fill", 20, 30);
            imageToFillGraphics.Circle(new Vector2(200, 150), 35, Color.Black);
            imageToFillGraphics.Circle(new Vector2(200, 150), 30, Color.Green);
            imageToFillGraphics.Rectangle(20, 50, 210, 280, Color.Black);
            imageToFillGraphics.Rectangle(imageToFillOn.Bounds, Color.Blue);
            Random rand = new Random();

            var stroke1 = new Stroke(1);
            var v1      = GetFreeVxs();
            var v2      = GetFreeVxs();

            for (int i = 0; i < 20; i++)
            {
                Ellipse elipse = new Ellipse(rand.Next(imageToFillOn.Width), rand.Next(imageToFillOn.Height), rand.Next(10, 60), rand.Next(10, 60));
                imageToFillGraphics.Render(stroke1.MakeVxs(elipse.MakeVxs(v1), v2), Color.Black);
            }
            ReleaseVxs(ref v1);
            ReleaseVxs(ref v2);
            this.PixelSize = 32;
            this.Gamma     = 1;
        }
Ejemplo n.º 3
0
        protected override void OnDrawSample(SKCanvas canvas, int width, int height)
        {
            if (!buildVxs)
            {
                destImg  = new ActualImage(400, 300, PixelFarm.Agg.PixelFormat.ARGB32);
                imgGfx2d = new ImageGraphics2D(destImg); //no platform
                p        = new AggCanvasPainter(imgGfx2d);

                buildVxs = true;
                ReadAndRender("tahoma.ttf", "A");
            }

            canvas.Clear(SKColors.White);

            using (SKBitmap bitmap = new SKBitmap(destImg.Width, destImg.Height, false))
            {
                //IntPtr pixelHeader = bitmap.GetPixels();
                //byte[] srcBuffer = ActualImage.GetBuffer(destImg);
                bitmap.LockPixels();
                //System.Runtime.InteropServices.Marshal.Copy(
                //    srcBuffer, 0,
                //    pixelHeader, srcBuffer.Length);
                //bitmap.UnlockPixels();
                PixelFarm.Agg.Imaging.BitmapHelper.CopyToGdiPlusBitmapSameSize(
                    destImg, destImg.Width, destImg.Height,
                    destImg.Stride, bitmap.GetPixels());
                bitmap.UnlockPixels();
                canvas.DrawBitmap(bitmap, 10, 10);
            }
        }
 public void BindHostGraphics(Graphics hostControlGraphics)
 {
     g = hostControlGraphics;
     //
     destImg  = new ActualImage(400, 300, PixelFormat.ARGB32);
     imgGfx2d = new ImageGraphics2D(destImg); //no platform
     p        = new AggCanvasPainter(imgGfx2d);
     winBmp   = new Bitmap(400, 300, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
 }
Ejemplo n.º 5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }
            //
            _basicOptions = basicFontOptionsUserControl1.Options;
            _basicOptions.TypefaceChanged += (s, e2) =>
            {
                if (_devVxsTextPrinter != null)
                {
                    _devVxsTextPrinter.Typeface = e2.SelectedTypeface;
                }
            };
            _basicOptions.UpdateRenderOutput += (s, e2) =>
            {
                UpdateRenderOutput();
            };
            //
            //----------
            _renderOptions = glyphRenderOptionsUserControl1.Options;
            _renderOptions.UpdateRenderOutput += (s, e2) =>
            {
                UpdateRenderOutput();
            };

            //share text printer to our sample textbox
            //but you can create another text printer that specific to text textbox control

            destImg  = new ActualImage(800, 600, PixelFormat.ARGB32);
            imgGfx2d = new ImageGraphics2D(destImg); //no platform
            painter  = new AggCanvasPainter(imgGfx2d);
            winBmp   = new Bitmap(destImg.Width, destImg.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            g        = this.sampleTextBox1.CreateGraphics();

            painter.CurrentFont = new PixelFarm.Drawing.RequestFont("tahoma", 14);

            _devVxsTextPrinter = new VxsTextPrinter(painter, _basicOptions.OpenFontStore);

            _devVxsTextPrinter.ScriptLang        = _basicOptions.ScriptLang;
            _devVxsTextPrinter.PositionTechnique = Typography.TextLayout.PositionTechnique.OpenFont;
            _devVxsTextPrinter.FontSizeInPoints  = 10;

            _controllerForPixelFarm.BindHostGraphics(g);
            _controllerForPixelFarm.TextPrinter = _devVxsTextPrinter;

            this.sampleTextBox1.SetController(_controllerForPixelFarm);
            _readyToRender = true;
            _basicOptions.UpdateRenderOutput += (s, e2) => UpdateRenderOutput();
            //----------
            //txtInputChar.TextChanged += (s, e2) => UpdateRenderOutput();
            //----------
        }
Ejemplo n.º 6
0
 void UpdateRenderOutput()
 {
     if (g == null)
     {
         destImg  = new ActualImage(400, 300, PixelFormat.ARGB32);
         imgGfx2d = new ImageGraphics2D(destImg); //no platform
         p        = new AggCanvasPainter(imgGfx2d);
         winBmp   = new Bitmap(400, 300, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
         g        = this.CreateGraphics();
     }
     ReadAndRender(_currentSelectedFontFile);
 }
        public void BindHostGraphics(Graphics hostControlGraphics)
        {
            g = hostControlGraphics;
            //
            destImg  = new ActualImage(400, 300, PixelFormat.ARGB32);
            imgGfx2d = new ImageGraphics2D(destImg); //no platform
            p        = new AggCanvasPainter(imgGfx2d);
            winBmp   = new Bitmap(400, 300, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            _printer    = new VxsTextPrinter(p, null);
            _visualLine = new VisualLine();
            _visualLine.BindLine(_line);
            _visualLine.Y = 100;
        }
Ejemplo n.º 8
0
        void RunSampleA(CanvasPainter p)
        {
            //1. create simple vertical line to test agg's lcd rendernig technique
            //create gray-scale actual image
            ActualImage      glyphImg = new ActualImage(100, 100, PixelFormat.ARGB32);
            ImageGraphics2D  glyph2d  = new ImageGraphics2D(glyphImg);
            AggCanvasPainter painter  = new AggCanvasPainter(glyph2d);

            painter.StrokeColor = PixelFarm.Drawing.Color.Black;
            painter.StrokeWidth = 2.0f * 3;
            int x = 10, y = 10;

            painter.Line(x * 3, 0, y * 3, 20); //scale horizontal 3 times,
            int lineLen = 4;


            //painter.Line(x * 3, 0, y * 3, 20); //scale horizontal 3 times,
            //painter.Line(2, 0, 2, 15);
            //painter.Line(2, 0, 20, 20);
            //painter.Line(2, 0, 30, 15);
            //painter.Line(2, 0, 30, 5);
            //clear surface bg
            p.Clear(PixelFarm.Drawing.Color.White);
            //draw img into that bg
            //---------------
            //convert glyphImg from RGBA to grey Scale buffer
            //---------------
            //lcd process ...
            byte[] glyphGreyScale = CreateGreyScaleBuffer(glyphImg);
            //---------------

            //swap gray scale
            int newGreyImgStride;

            byte[] expanedGreyScaleBuffer = CreateNewExpandedLcdGrayScale(glyphGreyScale, glyphImg.Width, glyphImg.Height, out newGreyImgStride);

            //blend lcd
            var aggPainer = (PixelFarm.Agg.AggCanvasPainter)p;

            Blend(aggPainer.Graphics.DestActualImage, expanedGreyScaleBuffer, newGreyImgStride, glyphImg.Height);
            //---------------
            p.DrawImage(glyphImg, 0, 50);
        }
Ejemplo n.º 9
0
        void SoftAggControl_Load(object sender, EventArgs e)
        {
            if (_useGdiPlusOutput)
            {
                // This example assumes the existence of a form called Form1.
                // Gets a reference to the current BufferedGraphicsContext
                //BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current;
                //_myBuffGfx = currentContext.Allocate(this.CreateGraphics(),
                //   this.DisplayRectangle);

                // Creates a BufferedGraphics instance associated with Form1, and with
                // dimensions the same size as the drawing surface of Form1.

                thisGfx       = this.CreateGraphics(); //for render to output
                bufferBmpRect = this.DisplayRectangle;
                bufferBmp     = new Bitmap(bufferBmpRect.Width, bufferBmpRect.Height);
                //_g = Graphics.FromImage(bufferBmp);
                //if (_gdiAntiAlias)
                //{
                //    _g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                //}
                //else
                //{
                //    _g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
                //}

                var p = new PixelFarm.Drawing.WinGdi.GdiPlusCanvasPainter(bufferBmp);
                painter         = p;
                p.SmoothingMode = _gdiAntiAlias ? System.Drawing.Drawing2D.SmoothingMode.AntiAlias : System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
            }
            else
            {
                ImageGraphics2D imgGfx2d = bitmapBackBuffer.Initialize(myWidth, myHeight, 32);
                //-------------
                string fontfile = "c:\\Windows\\Fonts\\tahoma.ttf";
                //-------------
                painter             = new AggCanvasPainter(imgGfx2d);
                painter.CurrentFont = PixelFarm.Agg.Fonts.NativeFontStore.LoadFont(fontfile, 10);
            }
            painter.Clear(ColorRGBA.White);
        }
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            lionShape = new SpriteShape();
            lionShape.ParseLion();
            RectD lionBounds = lionShape.Bounds;

            //-------------
            aggImage   = new ActualImage((int)lionBounds.Width, (int)lionBounds.Height, PixelFarm.Agg.PixelFormat.ARGB32);
            imgGfx2d   = new ImageGraphics2D(aggImage);
            aggPainter = new AggCanvasPainter(imgGfx2d);

            DrawLion(aggPainter, lionShape, lionShape.Path.Vxs);
            //convert affImage to texture
            glBmp = LoadTexture(aggImage);

            int max = Math.Max(this.Width, this.Height);

            canvas2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max);
            //-------------------------
            painter = new GLCanvasPainter(canvas2d, max, max);
        }
Ejemplo n.º 11
0
        void RunSampleB(CanvasPainter p)
        {
            //version 2:
            //1. create simple vertical line to test agg's lcd rendernig technique
            //create gray-scale actual image
            ActualImage      glyphImg = new ActualImage(100, 100, PixelFormat.ARGB32);
            ImageGraphics2D  glyph2d  = new ImageGraphics2D(glyphImg);
            AggCanvasPainter painter  = new AggCanvasPainter(glyph2d);

            //
            painter.StrokeColor = PixelFarm.Drawing.Color.Black;
            painter.StrokeWidth = 2.0f;
            painter.Line(2, 0, 3, 15);//not need to scale3
            //
            //clear surface bg
            p.Clear(PixelFarm.Drawing.Color.White);
            //--------------------------
            var aggPainer = (PixelFarm.Agg.AggCanvasPainter)p;

            BlendWithLcdTechnique(aggPainer.Graphics.DestActualImage, glyphImg, PixelFarm.Drawing.Color.Black);
            //---------------
            p.DrawImage(glyphImg, 0, 50);
            //---------------
        }
Ejemplo n.º 12
0
        public AggTextSpanPrinter(GLCanvasPainter canvasPainter, int w, int h)
        {
            //this class print long text into agg canvas
            //then copy pixel buffer from aff canvas to gl-bmp
            //then draw the  gl-bmp into target gl canvas


            //TODO: review here
            this.canvasPainter = canvasPainter;
            this.canvas        = canvasPainter.Canvas;
            bmpWidth           = w;
            bmpHeight          = h;
            actualImage        = new ActualImage(bmpWidth, bmpHeight, PixelFormat.ARGB32);

            imgGfx2d                = new ImageGraphics2D(actualImage);
            _aggPainter             = new AggCanvasPainter(imgGfx2d);
            _aggPainter.FillColor   = Color.Black;
            _aggPainter.StrokeColor = Color.Black;

            //set default1
            _aggPainter.CurrentFont = canvasPainter.CurrentFont;
            textPrinter             = new VxsTextPrinter(_aggPainter, YourImplementation.BootStrapOpenGLES2.myFontLoader);
            _aggPainter.TextPrinter = textPrinter;
        }
Ejemplo n.º 13
0
        public override void DrawRect(CGRect dirtyRect)
        {
            if (!drawInit)
            {
                this.Window.Title = "PixelFarm";
                drawInit          = true;
                destImg           = new ActualImage(destImgW, destImgH, PixelFarm.Agg.PixelFormat.ARGB32);
                imgGfx2d          = new ImageGraphics2D(destImg);        //no platform
                p      = new AggCanvasPainter(imgGfx2d);
                stride = destImg.Stride;
                LoadGlyphs();
            }
            //base.Draw(rect);
            base.DrawRect(dirtyRect);


            p.Clear(Color.Yellow);
            p.FillColor = Color.Black;
            p.Fill(vxs);

            var            data     = Foundation.NSData.FromArray(ActualImage.GetBuffer(destImg));
            CGDataProvider provider = new CGDataProvider(data);

            using (var myImg2 = new CGImage(
                       destImgW, destImgH,
                       8, 32,
                       stride, CGColorSpace.CreateGenericRgb(),
                       CGBitmapFlags.PremultipliedLast,
                       provider,
                       null, true,
                       CGColorRenderingIntent.AbsoluteColorimetric))

                using (var nsGraphics = AppKit.NSGraphicsContext.CurrentContext)
                {
                    CGContext g      = nsGraphics.CGContext;
                    CGColor   color0 = new CGColor(1, 1, 1, 1);
                    g.SetFillColor(color0);
                    //g.ClearRect(new CGRect(0, 0, 800, 600));
                    //----------

                    CGColor color1 = new CGColor(1, 0, 0, 1);
                    g.SetFillColor(color1);

                    CGRect s1    = CGRect.FromLTRB(0, 0, 50, 50);
                    CGPath gpath = new CGPath();
                    gpath.AddRect(CGAffineTransform.MakeTranslation(20, 20), s1);
                    g.AddPath(gpath);
                    g.FillPath();


                    CGRect s2 = new CGRect(50, 50, destImgW, destImgH);
                    g.DrawImage(s2, myImg2);

                    //

                    //g.FillRect(s1);

                    CGColor color2 = new CGColor(0, 0, 1, 1);
                    g.SetFillColor(color2);
                    g.TranslateCTM(30, 30);


                    var strAttr = new CTStringAttributes
                    {
                        ForegroundColorFromContext = true,
                        Font = new CTFont("Arial", 24)
                    };


                    g.ScaleCTM(1, -1);            //flip
                    NSAttributedString a_str = new NSAttributedString("abcd", strAttr);
                    using (CTLine line = new CTLine(a_str))
                    {
                        line.Draw(g);
                    }


                    ////if (chkBorder.Checked)
                    ////{
                    ////	//5.4
                    ////	p.StrokeColor = PixelFarm.Drawing.Color.Green;
                    ////	//user can specific border width here...
                    ////	//p.StrokeWidth = 2;
                    ////	//5.5
                    ////	p.Draw(vxs);
                    ////}
                    ////6. use this util to copy image from Agg actual image to System.Drawing.Bitmap
                    //BitmapHelper.CopyToWindowsBitmap(destImg, winBmp, new RectInt(0, 0, 300, 300));
                    ////---------------
                    ////7. just render our bitmap
                    //g.ClearRect(rect);

                    //g.DrawImage(winBmp, new Point(10, 0));
                }



            //// scale and translate the CTM so the image appears upright
            //g.ScaleCTM (1, -1);
            //g.TranslateCTM (0, -Bounds.Height);
            //g.DrawImage (rect, UIImage.FromFile ("MyImage.png").CGImage);
            //// translate the CTM by the font size so it displays on screen
            //float fontSize = 35f;
            //g.TranslateCTM (0, fontSize);

            //// set general-purpose graphics state
            //g.SetLineWidth (1.0f);
            //g.SetStrokeColor (UIColor.Yellow.CGColor);
            //g.SetFillColor (UIColor.Red.CGColor);
            //g.SetShadow (new CGSize (5, 5), 0, UIColor.Blue.CGColor);

            //// set text specific graphics state
            //g.SetTextDrawingMode (CGTextDrawingMode.FillStroke);
            //g.SelectFont ("Helvetica", fontSize, CGTextEncoding.MacRoman);

            //// show the text
            //g.ShowText ("Hello Core Graphics");
        }
Ejemplo n.º 14
0
        void UpdateRenderOutput()
        {
            if (!_readyToRender)
            {
                return;
            }
            //
            if (g == null)
            {
                destImg  = new ActualImage(800, 600, PixelFormat.ARGB32);
                imgGfx2d = new ImageGraphics2D(destImg); //no platform
                painter  = new AggCanvasPainter(imgGfx2d);
                winBmp   = new Bitmap(destImg.Width, destImg.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                g        = this.CreateGraphics();

                painter.CurrentFont = new PixelFarm.Drawing.RequestFont("tahoma", 14);

                _devVxsTextPrinter = new VxsTextPrinter(painter, _basicOptions.OpenFontStore);
                _devVxsTextPrinter.TargetCanvasPainter = painter;
                _devVxsTextPrinter.ScriptLang          = _basicOptions.ScriptLang;
                _devVxsTextPrinter.PositionTechnique   = Typography.TextLayout.PositionTechnique.OpenFont;
                //_devGdiTextPrinter.TargetGraphics = g;
            }

            if (string.IsNullOrEmpty(this.txtInputChar.Text))
            {
                return;
            }

            //test option use be used with lcd subpixel rendering.
            //this demonstrate how we shift a pixel for subpixel rendering tech
            _devVxsTextPrinter.UseWithLcdSubPixelRenderingTechnique = _contourAnalysisOpts.SetupPrinterLayoutForLcdSubPix;



            //1. read typeface from font file
            TypographyTest.RenderChoice renderChoice = _basicOptions.RenderChoice;
            switch (renderChoice)
            {
            case TypographyTest.RenderChoice.RenderWithGdiPlusPath:
                //not render in this example
                //see more at ...
                break;

            case TypographyTest.RenderChoice.RenderWithTextPrinterAndMiniAgg:
            {
                //clear previous draw
                painter.Clear(PixelFarm.Drawing.Color.White);
                painter.UseSubPixelRendering = _contourAnalysisOpts.LcdTechnique;
                painter.FillColor            = PixelFarm.Drawing.Color.Black;

                selectedTextPrinter                   = _devVxsTextPrinter;
                selectedTextPrinter.Typeface          = _basicOptions.Typeface;
                selectedTextPrinter.FontSizeInPoints  = _basicOptions.FontSizeInPoints;
                selectedTextPrinter.ScriptLang        = _basicOptions.ScriptLang;
                selectedTextPrinter.PositionTechnique = _basicOptions.PositionTech;

                selectedTextPrinter.HintTechnique  = _glyphRenderOptions.HintTechnique;
                selectedTextPrinter.EnableLigature = _glyphRenderOptions.EnableLigature;

                //test print 3 lines
#if DEBUG
                GlyphDynamicOutline.dbugTestNewGridFitting    = _contourAnalysisOpts.EnableGridFit;
                GlyphDynamicOutline.dbugActualPosToConsole    = _contourAnalysisOpts.WriteFitOutputToConsole;
                GlyphDynamicOutline.dbugUseHorizontalFitValue = _contourAnalysisOpts.UseHorizontalFitAlignment;
#endif

                char[] printTextBuffer = this.txtInputChar.Text.ToCharArray();
                float  x_pos = 0, y_pos = 200;
                float  lineSpacingPx = selectedTextPrinter.FontLineSpacingPx;
                for (int i = 0; i < 1; ++i)
                {
                    selectedTextPrinter.DrawString(printTextBuffer, x_pos, y_pos);
                    y_pos -= lineSpacingPx;
                }


                //copy from Agg's memory buffer to gdi
                PixelFarm.Agg.Imaging.BitmapHelper.CopyToGdiPlusBitmapSameSize(destImg, winBmp);
                g.Clear(Color.White);
                g.DrawImage(winBmp, new Point(10, 0));
            }
            break;

            //==============================================
            //render 1 glyph for debug and test
            case TypographyTest.RenderChoice.RenderWithMsdfGen:
            case TypographyTest.RenderChoice.RenderWithSdfGen:
            {
                char     testChar = this.txtInputChar.Text[0];
                Typeface typeFace = _basicOptions.Typeface;
                RenderWithMsdfImg(typeFace, testChar, _basicOptions.FontSizeInPoints);
            }
            break;

            case TypographyTest.RenderChoice.RenderWithMiniAgg_SingleGlyph:
            {
                selectedTextPrinter = _devVxsTextPrinter;
                //for test only 1 char
                RenderSingleCharWithMiniAgg(
                    _basicOptions.Typeface,
                    this.txtInputChar.Text[0],
                    _basicOptions.FontSizeInPoints);
            }
            break;

            default:
                throw new NotSupportedException();
            }
        }
Ejemplo n.º 15
0
        void UpdateRenderOutput()
        {
            if (g == null)
            {
                destImg  = new ActualImage(400, 300, PixelFormat.ARGB32);
                imgGfx2d = new ImageGraphics2D(destImg); //no platform
                p        = new AggCanvasPainter(imgGfx2d);
                winBmp   = new Bitmap(400, 300, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                g        = this.CreateGraphics();

                _devVxsTextPrinter.TargetCanvasPainter = p;
                _devGdiTextPrinter.TargetGraphics      = g;
            }

            if (string.IsNullOrEmpty(this.txtInputChar.Text))
            {
                return;
            }

            var hintTech = (HintTechnique)lstHintList.SelectedItem;

            //1. read typeface from font file
            RenderChoice renderChoice = (RenderChoice)this.cmbRenderChoices.SelectedItem;

            switch (renderChoice)
            {
            case RenderChoice.RenderWithGdiPlusPath:
            {
                selectedTextPrinter = _devGdiTextPrinter;
                selectedTextPrinter.FontFilename      = _selectedFontFilename;
                selectedTextPrinter.FontSizeInPoints  = _fontSizeInPts;
                selectedTextPrinter.HintTechnique     = hintTech;
                selectedTextPrinter.PositionTechnique = (PositionTechnique)cmbPositionTech.SelectedItem;
                //
                selectedTextPrinter.DrawString(this.txtInputChar.Text.ToCharArray(), 0, 0);
            }
            break;

            case RenderChoice.RenderWithTextPrinterAndMiniAgg:
            {
                //clear previous draw
                p.Clear(PixelFarm.Drawing.Color.White);
                p.UseSubPixelRendering = chkLcdTechnique.Checked;
                p.FillColor            = PixelFarm.Drawing.Color.Black;

                selectedTextPrinter = _devVxsTextPrinter;
                selectedTextPrinter.FontFilename      = _selectedFontFilename;
                selectedTextPrinter.FontSizeInPoints  = _fontSizeInPts;
                selectedTextPrinter.HintTechnique     = hintTech;
                selectedTextPrinter.PositionTechnique = (PositionTechnique)cmbPositionTech.SelectedItem;

                //test print 3 lines

                char[] printTextBuffer = this.txtInputChar.Text.ToCharArray();
                float  x_pos = 0, y_pos = 200;
                float  lineSpacingPx = selectedTextPrinter.FontLineSpacingPx;
                for (int i = 0; i < 3; ++i)
                {
                    selectedTextPrinter.DrawString(printTextBuffer, x_pos, y_pos);
                    y_pos -= lineSpacingPx;
                }


                //copy from Agg's memory buffer to gdi
                PixelFarm.Agg.Imaging.BitmapHelper.CopyToGdiPlusBitmapSameSize(destImg, winBmp);
                g.Clear(Color.White);
                g.DrawImage(winBmp, new Point(10, 0));
            }
            break;


            //==============================================
            //render 1 glyph for debug and test
            case RenderChoice.RenderWithMsdfGen:
            case RenderChoice.RenderWithSdfGen:
            {
                char testChar = this.txtInputChar.Text[0];
                using (var fs = new FileStream(_selectedFontFilename, FileMode.Open))
                {
                    var      reader   = new OpenFontReader();
                    Typeface typeFace = reader.Read(fs);
                    RenderWithMsdfImg(typeFace, testChar, _fontSizeInPts);
                }
            }
            break;

            case RenderChoice.RenderWithMiniAgg_SingleGlyph:
            {
                //for test only 1 char
                char testChar = this.txtInputChar.Text[0];
                using (var fs = new FileStream(_selectedFontFilename, FileMode.Open))
                {
                    var      reader   = new OpenFontReader();
                    Typeface typeFace = reader.Read(fs);
                    RenderWithMiniAgg(typeFace, testChar, _fontSizeInPts);
                }
            }
            break;

            default:
                throw new NotSupportedException();
            }
        }