public override void Draw(PixelFarm.Drawing.Painter p) { AggPainter aggPainter = (AggPainter)p; //---------------- //5. use PixelFarm's Agg to render to bitmap... //5.1 clear background p.Clear(PixelFarm.Drawing.Color.White); if (FillBG) { //5.2 p.FillColor = PixelFarm.Drawing.Color.Black; //5.3 //p.Fill(vxs); float x = aggPainter.OriginX; float y = aggPainter.OriginY; p.Fill(left_vxs); aggPainter.SetOrigin(x + 50, y + 20); p.Fill(right_vxs); aggPainter.SetOrigin(x, y); } if (FillBorder) { //5.4 p.StrokeColor = PixelFarm.Drawing.Color.Green; //user can specific border width here... //p.StrokeWidth = 2; //5.5 //p.Draw(vxs); float x = aggPainter.OriginX; float y = aggPainter.OriginY; p.Fill(left_vxs); aggPainter.SetOrigin(x + 50, y + 20); p.Fill(right_vxs); aggPainter.SetOrigin(x, y); } }
void RenderSingleCharWithMiniAgg(Typeface typeface, char testChar, float sizeInPoint) { //--------------- //set up vinfo UI.DebugGlyphVisualizerInfoView vinfo = _debugGlyphVisualizer.VisualizeInfoView; if (vinfo == null) { vinfo = new UI.DebugGlyphVisualizerInfoView(); vinfo.SetTreeView(glyphContourAnalysisOptionsUserControl1.DebugTreeView); vinfo.SetFlushOutputHander(() => { _painter.SetOrigin(0, 0); //6. use this util to copy image from Agg actual image to System.Drawing.Bitmap PixelFarm.CpuBlit.Imaging.BitmapHelper.CopyToGdiPlusBitmapSameSize(_destImg, _winBmp); //--------------- //7. just render our bitmap _g.Clear(Color.White); _g.DrawImage(_winBmp, new Point(30, 100)); }); _debugGlyphVisualizer.VisualizeInfoView = vinfo; } //--------------- //we use the debugGlyphVisualize the render it _debugGlyphVisualizer.SetFont(typeface, sizeInPoint); _debugGlyphVisualizer.CanvasPainter = _painter; _debugGlyphVisualizer.UseLcdTechnique = _contourAnalysisOpts.LcdTechnique; _debugGlyphVisualizer.FillBackGround = _glyphRenderOptions.FillBackground; _debugGlyphVisualizer.DrawBorder = _glyphRenderOptions.DrawBorder; _debugGlyphVisualizer.ShowTess = _contourAnalysisOpts.ShowTess; _debugGlyphVisualizer.WalkTrianglesAndEdges = _contourAnalysisOpts.ShowTriangle; _debugGlyphVisualizer.DrawEndLineHub = _contourAnalysisOpts.DrawLineHubConn; _debugGlyphVisualizer.DrawPerpendicularLine = _contourAnalysisOpts.DrawPerpendicularLine; _debugGlyphVisualizer.WalkCentroidBone = _contourAnalysisOpts.DrawCentroidBone; _debugGlyphVisualizer.WalkGlyphBone = _contourAnalysisOpts.DrawGlyphBone; _debugGlyphVisualizer.GlyphEdgeOffset = _contourAnalysisOpts.EdgeOffset; _debugGlyphVisualizer.DrawDynamicOutline = _contourAnalysisOpts.DynamicOutline; _debugGlyphVisualizer.DrawRegenerateOutline = _contourAnalysisOpts.DrawRegenerationOutline; _debugGlyphVisualizer.DrawGlyphPoint = _contourAnalysisOpts.DrawGlyphPoint; #if DEBUG GlyphDynamicOutline.dbugTestNewGridFitting = _contourAnalysisOpts.EnableGridFit; GlyphDynamicOutline.dbugActualPosToConsole = _contourAnalysisOpts.WriteFitOutputToConsole; GlyphDynamicOutline.dbugUseHorizontalFitValue = _contourAnalysisOpts.UseHorizontalFitAlignment; #endif //------------------------------------------------------ _debugGlyphVisualizer.RenderChar(testChar, _glyphRenderOptions.HintTechnique); //---------------------------------------------------- //-------------------------- if (_contourAnalysisOpts.ShowGrid) { //render grid RenderGrids(800, 600, _gridSize, _painter); } _painter.SetOrigin(0, 0); //6. use this util to copy image from Agg actual image to System.Drawing.Bitmap PixelFarm.CpuBlit.Imaging.BitmapHelper.CopyToGdiPlusBitmapSameSize(_destImg, _winBmp); //--------------- //7. just render our bitmap _g.Clear(Color.White); _g.DrawImage(_winBmp, new Point(30, 100)); //g.DrawRectangle(Pens.White, new System.Drawing.Rectangle(30, 20, winBmp.Width, winBmp.Height)); }