public MiniAggCanvasRenderElement(RootGraphic rootgfx, int width, int height)
            : base(rootgfx, width, height)
        {

            this.actualImage = new ActualImage(width, height, PixelFarm.Agg.PixelFormat.ARGB32);
            this.gfx2d = Graphics2D.CreateFromImage(actualImage);
            this.painter = new AggCanvasPainter((ImageGraphics2D)gfx2d);
            needUpdate = true;
            this.BackColor = Color.White;
        }
Ejemplo n.º 2
0
        public void Print(CanvasPainter painter, char[] buffer, double x, double y)
        {
            int j = buffer.Length;
            int buffsize = j * 2;
            //get kerning list 

            ProperGlyph[] properGlyphs = new ProperGlyph[buffsize];
            ActualFont implFont = actualFont;
            TextShapingService.GetGlyphPos(actualFont, buffer, 0, buffsize, properGlyphs);
            double xpos = x;
            for (int i = 0; i < buffsize; ++i)
            {
                uint codepoint = properGlyphs[i].codepoint;
                if (codepoint == 0)
                {
                    break;
                }
                //-------------------------------------------------------------
                FontGlyph glyph = implFont.GetGlyphByIndex(codepoint);
                //var left = glyph.glyphMatrix.img_horiBearingX;
                //--------------------------------------------------------
                //render with vector
                //var mat = Agg.Transform.Affine.NewMatix(
                //Agg.Transform.AffinePlan.Scale(0.30),
                //Agg.Transform.AffinePlan.Translate(xpos, y));
                //var vxs1 = mat.TransformToVxs(glyph.flattenVxs); 

                VertexStore vxs1 = Agg.Transform.Affine.TranslateToVxs(
                    glyph.flattenVxs,
                    (float)(xpos),
                    (float)(y),
                    vxsPool.GetFreeVxs());
                painter.Fill(vxs1);
                vxsPool.Release(ref vxs1);
                //--------------------------------------------------------
                ////render with bitmap
                //if (glyph.glyphImage32 != null)
                //{
                //    if (glyph.glyphImage32.Width > 0 && glyph.glyphImage32.Height > 0)
                //    {
                //        painter.DrawImage(glyph.glyphImage32,
                //            (float)(xpos + (left >> 6)),
                //            (float)(y + (glyph.exportGlyph.bboxYmin >> 6)));
                //    }
                //}
                int w = (glyph.glyphMatrix.advanceX) >> 6;
                xpos += (w);
                //-------------------------------------------------------------                
            }
        }
Ejemplo n.º 3
0
        public override void Draw(CanvasPainter p)
        {
            if (myvxs == null)
            {
                var transform = Affine.NewMatix(
                    AffinePlan.Translate(-lionShape.Center.x, -lionShape.Center.y),
                    AffinePlan.Scale(spriteScale, spriteScale),
                    AffinePlan.Rotate(angle + Math.PI),
                    AffinePlan.Skew(skewX / 1000.0, skewY / 1000.0),
                    AffinePlan.Translate(Width / 2, Height / 2)
                    );
                //create vertextStore again from original path
                myvxs = new VertexStore();

                transform.TransformToVxs(lionShape.Path.Vxs, myvxs);

                if (AutoFlipY)
                {
                    //flip the lion
                    PixelFarm.Agg.Transform.Affine aff = PixelFarm.Agg.Transform.Affine.NewMatix(
                        PixelFarm.Agg.Transform.AffinePlan.Scale(-1, -1),
                        PixelFarm.Agg.Transform.AffinePlan.Translate(0, 600));
                    //
                    var v2 = new VertexStore();
                    myvxs = transform.TransformToVxs(myvxs, v2);
                }
            }
            //---------------------------------------------------------------------------------------------
            {
                int             j        = lionShape.NumPaths;
                int[]           pathList = lionShape.PathIndexList;
                Drawing.Color[] colors   = lionShape.Colors;
                //graphics2D.UseSubPixelRendering = true;
                for (int i = 0; i < j; ++i)
                {
                    p.FillColor = colors[i];
                    p.Fill(new VertexStoreSnap(myvxs, pathList[i]));
                }
            }
        }
Ejemplo n.º 4
0
        public override void Draw(CanvasPainter p)
        {
            //specific for agg
            if (!(p is AggCanvasPainter))
            {
                return;
            }


            AggCanvasPainter p2         = (AggCanvasPainter)p;
            Graphics2D       graphics2D = p2.Graphics;

            if (graphics2D.DestImage != null)
            {
                IImageReaderWriter backBuffer          = graphics2D.DestImage;
                IPixelBlender      currentPixelBlender = graphics2D.PixelBlender;
                int distBetween = backBuffer.BytesBetweenPixelsInclusive;
                //use different pixel blender
                var                redImageBuffer     = new ChildImage(backBuffer, new PixelBlenderGray(distBetween), distBetween, CO.R, 8);
                var                greenImageBuffer   = new ChildImage(backBuffer, new PixelBlenderGray(distBetween), distBetween, CO.G, 8);
                var                blueImageBuffer    = new ChildImage(backBuffer, new PixelBlenderGray(distBetween), distBetween, CO.B, 8);
                ClipProxyImage     clippingProxy      = new ClipProxyImage(backBuffer);
                ClipProxyImage     clippingProxyRed   = new ClipProxyImage(redImageBuffer);
                ClipProxyImage     clippingProxyGreen = new ClipProxyImage(greenImageBuffer);
                ClipProxyImage     clippingProxyBlue  = new ClipProxyImage(blueImageBuffer);
                ScanlineRasterizer sclineRas          = graphics2D.ScanlineRasterizer;
                ScanlinePacked8    scline             = graphics2D.ScanlinePacked8;
                ColorRGBA          clearColor         = this.UseBlackBlackground ? new ColorRGBA(0, 0, 0) : new ColorRGBA(255, 255, 255);
                clippingProxy.Clear(clearColor);
                ColorRGBA fillColor = this.UseBlackBlackground ?
                                      new ColorRGBA(255, 255, 255, (byte)(this.AlphaValue)) :
                                      new ColorRGBA(0, 0, 0, (byte)(this.AlphaValue));
                ScanlineRasToDestBitmapRenderer sclineRasToBmp = graphics2D.ScanlineRasToDestBitmap;
                VertexSource.Ellipse            er             = new PixelFarm.Agg.VertexSource.Ellipse(Width / 2 - 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
                sclineRas.AddPath(er.MakeVertexSnap());
                sclineRasToBmp.RenderWithColor(clippingProxyRed, sclineRas, scline, fillColor);
                VertexSource.Ellipse eg = new PixelFarm.Agg.VertexSource.Ellipse(Width / 2 + 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
                sclineRas.AddPath(eg.MakeVertexSnap());
                sclineRasToBmp.RenderWithColor(clippingProxyGreen, sclineRas, scline, fillColor);
                VertexSource.Ellipse eb = new PixelFarm.Agg.VertexSource.Ellipse(Width / 2, Height / 2 + 50, 100, 100, 100);
                sclineRas.AddPath(eb.MakeVertexSnap());
                sclineRasToBmp.RenderWithColor(clippingProxyBlue, sclineRas, scline, fillColor);
            }
            //            else if (graphics2D.DestImageFloat != null)
            //            {
            //#if false
            //                IImageFloat backBuffer = graphics2D.DestImageFloat;

            //                int distBetween = backBuffer.GetFloatsBetweenPixelsInclusive();
            //                ImageBufferFloat redImageBuffer = new ImageBufferFloat();
            //                redImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 2, 8);
            //                ImageBufferFloat greenImageBuffer = new ImageBufferFloat();
            //                greenImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 1, 8);
            //                ImageBufferFloat blueImageBuffer = new ImageBufferFloat();
            //                blueImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 0, 8);

            //                ImageClippingProxy clippingProxy = new ImageClippingProxy(backBuffer);
            //                ImageClippingProxy clippingProxyRed = new ImageClippingProxy(redImageBuffer);
            //                ImageClippingProxy clippingProxyGreen = new ImageClippingProxy(greenImageBuffer);
            //                ImageClippingProxy clippingProxyBlue = new ImageClippingProxy(blueImageBuffer);

            //                ScanlineRasterizer ras = new ScanlineRasterizer();
            //                ScanlineCachePacked8 sl = new ScanlineCachePacked8();

            //                RGBA_Bytes clearColor = useBlackBackgroundCheckbox.Checked ? new RGBA_Bytes(0, 0, 0) : new RGBA_Bytes(255, 255, 255);
            //                clippingProxy.clear(clearColor);
            //                alphaSlider.View.BackGroundColor = clearColor;

            //                RGBA_Bytes FillColor = useBlackBackgroundCheckbox.Checked ? new RGBA_Bytes(255, 255, 255, (int)(alphaSlider.Value)) : new RGBA_Bytes(0, 0, 0, (int)(alphaSlider.Value));

            //                VertexSource.Ellipse er = new AGG.VertexSource.Ellipse(Width / 2 - 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
            //                ras.add_path(er);
            //                agg_renderer_scanline.Default.render_scanlines_aa_solid(clippingProxyRed, ras, sl, FillColor);

            //                VertexSource.Ellipse eg = new AGG.VertexSource.Ellipse(Width / 2 + 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
            //                ras.add_path(eg);
            //                agg_renderer_scanline.Default.render_scanlines_aa_solid(clippingProxyGreen, ras, sl, FillColor);

            //                VertexSource.Ellipse eb = new AGG.VertexSource.Ellipse(Width / 2, Height / 2 + 50, 100, 100, 100);
            //                ras.add_path(eb);
            //                agg_renderer_scanline.Default.render_scanlines_aa_solid(clippingProxyBlue, ras, sl, FillColor);
            //#endif
            //            }
        }
Ejemplo n.º 5
0
 public virtual void Draw(CanvasPainter p)
 {
 }
Ejemplo n.º 6
0
 public void Print(CanvasPainter painter, string t, double x, double y)
 {
     Print(painter, t.ToCharArray(), x, y);
 }