Beispiel #1
0
 public AggCanvasPainter(ImageGraphics2D graphic2d)
 {
     this.gx             = graphic2d;
     this.sclineRas      = gx.ScanlineRasterizer;
     this.stroke         = new Stroke(1);//default
     this.scline         = graphic2d.ScanlinePacked8;
     this.sclineRasToBmp = graphic2d.ScanlineRasToDestBitmap;
 }
 public AggCanvasPainter(ImageGraphics2D graphic2d)
 {
     this.gx = graphic2d;
     this.sclineRas = gx.ScanlineRasterizer;
     this.stroke = new Stroke(1);//default
     this.scline = graphic2d.ScanlinePacked8;
     this.sclineRasToBmp = graphic2d.ScanlineRasToDestBitmap;
 }
Beispiel #3
0
        //-------------
        public CanvasPainter(Graphics2D graphic2d)
        {
            this.gx        = graphic2d;
            this.sclineRas = gx.ScanlineRasterizer;
            this.stroke    = new Stroke(1);//default

            this.scline         = graphic2d.ScanlinePacked8;
            this.sclineRasToBmp = graphic2d.ScanlineRasToDestBitmap;
            this.textPrinter    = new TextPrinter();
        }
Beispiel #4
0
 public void Draw(
     ScanlineRasToDestBitmapRenderer sclineRasToBmp,
     ScanlineRasterizer ras,
     Scanline sl,
     IImageReaderWriter destImage, ColorRGBA color,
     double x, double y)
 {
     ras.Reset();
     ras.MoveTo(x * m_size, y * m_size);
     ras.LineTo(x * m_size + m_size, y * m_size);
     ras.LineTo(x * m_size + m_size, y * m_size + m_size);
     ras.LineTo(x * m_size, y * m_size + m_size);
     sclineRasToBmp.RenderWithColor(destImage, ras, sl, color);
 }
 public ImageGraphics2D(ActualImage destImage)
 {
     //create from actual image
     this.destActualImage       = destImage;
     this.destImageReaderWriter = new MyImageReaderWriter(destImage);
     this.sclineRas             = new ScanlineRasterizer();
     this.sclineRasToBmp        = new ScanlineRasToDestBitmapRenderer();
     this.destWidth             = destImage.Width;
     this.destHeight            = destImage.Height;
     this.clipBox = new RectInt(0, 0, destImage.Width, destImage.Height);
     this.sclineRas.SetClipBox(this.clipBox);
     this.sclinePack8    = new ScanlinePacked8();
     this.currentBlender = this.pixBlenderRGBA32 = new PixelBlenderBGRA();
 }
Beispiel #6
0
        public AggPainter(AggRenderSurface aggsx)
        {
            this._aggsx         = aggsx;
            this.sclineRas      = _aggsx.ScanlineRasterizer;
            this.stroke         = new Stroke(1);//default
            this.scline         = aggsx.ScanlinePacked8;
            this.sclineRasToBmp = aggsx.ScanlineRasToDestBitmap;
            _orientation        = DrawBoardOrientation.LeftBottom;

            //from membuffer
            _bxt = new BitmapBuffer(aggsx.Width,
                                    aggsx.Height,
                                    PixelFarm.Agg.ActualImage.GetBuffer(aggsx.DestActualImage));
        }
 public static void RenderSolidAllPaths(this ScanlineRasToDestBitmapRenderer sclineRasToBmp,
                                        IImageReaderWriter destImage,
                                        ScanlineRasterizer sclineRas,
                                        Scanline scline,
                                        VertexStore vxs,
                                        Drawing.Color[] colors,
                                        int[] path_id,
                                        int num_paths)
 {
     for (int i = 0; i < num_paths; ++i)
     {
         sclineRas.Reset();
         sclineRas.AddPath(new VertexStoreSnap(vxs, path_id[i]));
         sclineRasToBmp.RenderWithColor(destImage, sclineRas, scline, colors[i]);
     }
 }
        public ImageGraphics2D(ActualImage destImage)
        {
            //create from actual image
            this.destImage = destImage;

            this.destActualImage = destImage;
            this.destImageReaderWriter = new MyImageReaderWriter();
            destImageReaderWriter.ReloadImage(destImage);
            this.sclineRas = new ScanlineRasterizer();
            this.sclineRasToBmp = new ScanlineRasToDestBitmapRenderer();
            this.destWidth = destImage.Width;
            this.destHeight = destImage.Height;
            this.clipBox = new RectInt(0, 0, destImage.Width, destImage.Height);
            this.sclineRas.SetClipBox(this.clipBox);
            this.sclinePack8 = new ScanlinePacked8();
            this.currentBlender = this.pixBlenderRGBA32 = new PixelBlenderBGRA();
        }
Beispiel #9
0
        public override void Draw(PixelFarm.Drawing.Painter p)
        {
            //specific for agg
            if (!(p is AggPainter))
            {
                return;
            }


            throw new NotSupportedException();

            AggPainter       p2      = (AggPainter)p;
            AggRenderSurface aggRdsf = p2.RenderSurface;

            if (aggRdsf.DestImage != null)
            {
                IImageReaderWriter backBuffer          = aggRdsf.DestImage;
                IPixelBlender      currentPixelBlender = aggRdsf.PixelBlender;
                int distBetween = backBuffer.BytesBetweenPixelsInclusive;
                //use different pixel blender
                var                redImageBuffer     = new SubImageRW(backBuffer, new PixelBlenderGray(distBetween), distBetween, CO.R, 8);
                var                greenImageBuffer   = new SubImageRW(backBuffer, new PixelBlenderGray(distBetween), distBetween, CO.G, 8);
                var                blueImageBuffer    = new SubImageRW(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          = aggRdsf.ScanlineRasterizer;
                ScanlinePacked8    scline             = aggRdsf.ScanlinePacked8;
                Drawing.Color      clearColor         = this.UseBlackBlackground ? Drawing.Color.FromArgb(0, 0, 0) : Drawing.Color.FromArgb(255, 255, 255);
                clippingProxy.Clear(clearColor);
                Drawing.Color fillColor = this.UseBlackBlackground ?
                                          new Drawing.Color((byte)(this.AlphaValue), 255, 255, 255) :
                                          new Drawing.Color((byte)(this.AlphaValue), 0, 0, 0);
                ScanlineRasToDestBitmapRenderer sclineRasToBmp = aggRdsf.ScanlineRasToDestBitmap;
                VertexSource.Ellipse            er             = new PixelFarm.Agg.VertexSource.Ellipse(Width / 2 - 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100);
                //
                VectorToolBox.GetFreeVxs(out var v1);
                sclineRas.AddPath(er.MakeVxs(v1));
                v1.Clear();
                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(v1));
                v1.Clear();

                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(v1));
                v1.Clear();
                sclineRasToBmp.RenderWithColor(clippingProxyBlue, sclineRas, scline, fillColor);

                VectorToolBox.ReleaseVxs(ref v1);
            }
            //            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
            //            }
        }
Beispiel #10
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
            //            }
        }