Пример #1
0
        public override void Draw(Painter p)
        {
            //specific for agg

            if (p is PixelFarm.Agg.AggPainter)
            {
                var p2 = (PixelFarm.Agg.AggPainter)p;
                AggRenderSurface   aggsx      = p2.RenderSurface;
                ScanlineRasterizer rasterizer = aggsx.ScanlineRasterizer;


                var widgetsSubImage = ImageHelper.CreateSubImgRW(aggsx.DestImage, aggsx.GetClippingRect());
                aggsx.UseSubPixelRendering = false;
                PixelBlenderBGRA normalBlender = new PixelBlenderBGRA();
                PixelBlenderBGRA gammaBlender  = new PixelBlenderBGRA(); //TODO: revisit, and fix this again
                gammaBlender.GammaValue  = this.GammaValue;
                gammaBlender.EnableGamma = true;
                var            rasterGamma         = new SubImageRW(widgetsSubImage, gammaBlender);
                ClipProxyImage clippingProxyNormal = new ClipProxyImage(widgetsSubImage);
                ClipProxyImage clippingProxyGamma  = new ClipProxyImage(rasterGamma);
                clippingProxyNormal.Clear(Color.White);

                ScanlineUnpacked8 sl = new ScanlineUnpacked8();
                int size_mul         = (int)this.PixelSize;
                CustomScanlineRasToBmp_EnlargedSubPixelRendering ren_en = new CustomScanlineRasToBmp_EnlargedSubPixelRendering(size_mul, aggsx.DestActualImage);
                rasterizer.Reset();
                rasterizer.MoveTo(m_x[0] / size_mul, m_y[0] / size_mul);
                rasterizer.LineTo(m_x[1] / size_mul, m_y[1] / size_mul);
                rasterizer.LineTo(m_x[2] / size_mul, m_y[2] / size_mul);
                ren_en.RenderWithColor(clippingProxyGamma, rasterizer, sl, Color.Black);
                //----------------------------------------
                ScanlineRasToDestBitmapRenderer sclineRasToBmp = aggsx.ScanlineRasToDestBitmap;
                aggsx.UseSubPixelRendering = false;
                sclineRasToBmp.RenderWithColor(clippingProxyGamma, rasterizer, sl, Color.Black);
                rasterizer.ResetGamma(new GammaNone());
                aggsx.UseSubPixelRendering = false;
                //----------------------------------------
                PathWriter ps = new PathWriter();
                ps.Clear();
                ps.MoveTo(m_x[0], m_y[0]);
                ps.LineTo(m_x[1], m_y[1]);
                ps.LineTo(m_x[2], m_y[2]);
                ps.LineTo(m_x[0], m_y[0]);
                //----------------------------------------
                //Stroke stroke = new Stroke(ps);
                //stroke.Width = 2;
                //rasterizer.AddPath(stroke.MakeVxs(ps.MakeVxs()));

                VectorToolBox.GetFreeVxs(out var v1);
                rasterizer.AddPath(stroke.MakeVxs(ps.Vxs, v1));
                VectorToolBox.ReleaseVxs(ref v1);
                //----------------------------------------

                sclineRasToBmp.RenderWithColor(clippingProxyNormal, rasterizer, sl, new Color(200, 0, 150, 160));
            }
        }
Пример #2
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);
 }
Пример #3
0
 public void Draw(
     DestBitmapRasterizer bmpRast,
     ScanlineRasterizer ras,
     Scanline sl,
     PixelProcessing.IBitmapBlender destImage, Color color,
     double x, double y)
 {
     ras.Reset();
     ras.MoveTo(x * _size, y * _size);
     ras.LineTo(x * _size + _size, y * _size);
     ras.LineTo(x * _size + _size, y * _size + _size);
     ras.LineTo(x * _size, y * _size + _size);
     bmpRast.RenderWithColor(destImage, ras, sl, color);
 }
Пример #4
0
        public override void Draw(Painter p)
        {
            //this specific for agg
            if (p is AggPainter)
            {
                AggPainter       p2    = (AggPainter)p;
                AggRenderSurface aggsx = p2.RenderSurface;
                PixelProcessing.SubBitmapBlender subImg = PixelProcessing.BitmapBlenderExtension.CreateSubBitmapBlender(aggsx.DestBitmapBlender, aggsx.GetClippingRect());

                //TODO: review here again
                PixelBlenderBGRA blenderWithGamma = new PixelProcessing.PixelBlenderBGRA();

                SubBitmapBlender rasterGamma         = new SubBitmapBlender(subImg, blenderWithGamma);
                ClipProxyImage   clippingProxyNormal = new ClipProxyImage(subImg);
                ClipProxyImage   clippingProxyGamma  = new ClipProxyImage(rasterGamma);
                clippingProxyNormal.Clear(Color.White);
                ScanlineRasterizer rasterizer = aggsx.ScanlineRasterizer;
                var sl             = new ScanlineUnpacked8();
                int size_mul       = this.PixelSize;
                var sclineToBmpEn2 = new CustomRas_EnlargeV2(size_mul, aggsx.DestBitmap);
                rasterizer.Reset();
                rasterizer.MoveTo(_x[0] / size_mul, _y[0] / size_mul);
                rasterizer.LineTo(_x[1] / size_mul, _y[1] / size_mul);
                rasterizer.LineTo(_x[2] / size_mul, _y[2] / size_mul);
                sclineToBmpEn2.RenderWithColor(clippingProxyGamma, rasterizer, sl, Color.Black);
                DestBitmapRasterizer bmpRas = aggsx.BitmapRasterizer;
                bmpRas.RenderWithColor(clippingProxyGamma, rasterizer, sl, Color.Black);
                //-----------------------------------------------------------------------------------------------------------
                rasterizer.ResetGamma(new GammaNone());

                using (VxsTemp.Borrow(out var v1, out var v2))
                    using (VectorToolBox.Borrow(v1, out PathWriter ps))
                    {
                        ps.Clear();
                        ps.MoveTo(_x[0], _y[0]);
                        ps.LineTo(_x[1], _y[1]);
                        ps.LineTo(_x[2], _y[2]);
                        ps.LineTo(_x[0], _y[0]);
                        rasterizer.AddPath((new Stroke(2)).MakeVxs(v1, v2));
                        bmpRas.RenderWithColor(clippingProxyNormal, rasterizer, sl, new Color(200, 0, 150, 160));
                    }
            }
        }
Пример #5
0
        public override void Draw(Painter p)
        {
            //this specific for agg
            if (p is AggPainter)
            {
                AggPainter       p2     = (AggPainter)p;
                AggRenderSurface aggsx  = p2.RenderSurface;
                SubImageRW       subImg = ImageHelper.CreateSubImgRW(aggsx.DestImage, aggsx.GetClippingRect());

                //TODO: review here again
                PixelBlenderBGRA blenderWithGamma = new PixelBlenderBGRA();

                SubImageRW     rasterGamma         = new SubImageRW(subImg, blenderWithGamma);
                ClipProxyImage clippingProxyNormal = new ClipProxyImage(subImg);
                ClipProxyImage clippingProxyGamma  = new ClipProxyImage(rasterGamma);
                clippingProxyNormal.Clear(Color.White);
                ScanlineRasterizer rasterizer = aggsx.ScanlineRasterizer;
                var sl             = new ScanlineUnpacked8();
                int size_mul       = this.PixelSize;
                var sclineToBmpEn2 = new CustomScanlineRasToBmp_EnlargedV2(size_mul, aggsx.DestActualImage);
                rasterizer.Reset();
                rasterizer.MoveTo(m_x[0] / size_mul, m_y[0] / size_mul);
                rasterizer.LineTo(m_x[1] / size_mul, m_y[1] / size_mul);
                rasterizer.LineTo(m_x[2] / size_mul, m_y[2] / size_mul);
                sclineToBmpEn2.RenderWithColor(clippingProxyGamma, rasterizer, sl, Color.Black);
                ScanlineRasToDestBitmapRenderer sclineRasToBmp = aggsx.ScanlineRasToDestBitmap;
                sclineRasToBmp.RenderWithColor(clippingProxyGamma, rasterizer, sl, Color.Black);
                //-----------------------------------------------------------------------------------------------------------
                rasterizer.ResetGamma(new GammaNone());
                PathWriter ps = new PathWriter();
                ps.Clear();
                ps.MoveTo(m_x[0], m_y[0]);
                ps.LineTo(m_x[1], m_y[1]);
                ps.LineTo(m_x[2], m_y[2]);
                ps.LineTo(m_x[0], m_y[0]);

                VectorToolBox.GetFreeVxs(out var v1);
                rasterizer.AddPath((new Stroke(2)).MakeVxs(ps.Vxs, v1));
                sclineRasToBmp.RenderWithColor(clippingProxyNormal, rasterizer, sl, new Color(200, 0, 150, 160));
                VectorToolBox.ReleaseVxs(ref v1);
            }
        }
Пример #6
0
        public override void Draw(Painter p)
        {
            //specific for agg

            if (p is PixelFarm.CpuBlit.AggPainter)
            {
                var p2 = (PixelFarm.CpuBlit.AggPainter)p;
                AggRenderSurface   aggsx      = p2.RenderSurface;
                ScanlineRasterizer rasterizer = aggsx.ScanlineRasterizer;


                var widgetsSubImage = PixelProcessing.BitmapBlenderExtension.CreateSubBitmapBlender(aggsx.DestBitmapBlender, aggsx.GetClippingRect());
                aggsx.UseSubPixelLcdEffect = false;
                PixelProcessing.PixelBlenderBGRA normalBlender = new PixelProcessing.PixelBlenderBGRA();
                PixelProcessing.PixelBlenderBGRA gammaBlender  = new PixelProcessing.PixelBlenderBGRA(); //TODO: revisit, and fix this again
                gammaBlender.GammaValue  = this.GammaValue;
                gammaBlender.EnableGamma = true;
                var            rasterGamma         = new PixelProcessing.SubBitmapBlender(widgetsSubImage, gammaBlender);
                ClipProxyImage clippingProxyNormal = new ClipProxyImage(widgetsSubImage);
                ClipProxyImage clippingProxyGamma  = new ClipProxyImage(rasterGamma);
                clippingProxyNormal.Clear(Color.White);

                ScanlineUnpacked8 sl = new ScanlineUnpacked8();
                int size_mul         = (int)this.PixelSize;
                CustomScanlineRasToBmp_EnlargedSubPixelRendering ren_en = new CustomScanlineRasToBmp_EnlargedSubPixelRendering(size_mul, aggsx.DestBitmap);
                rasterizer.Reset();
                rasterizer.MoveTo(_x[0] / size_mul, _y[0] / size_mul);
                rasterizer.LineTo(_x[1] / size_mul, _y[1] / size_mul);
                rasterizer.LineTo(_x[2] / size_mul, _y[2] / size_mul);
                ren_en.RenderWithColor(clippingProxyGamma, rasterizer, sl, Color.Black);
                //----------------------------------------
                DestBitmapRasterizer sclineRasToBmp = aggsx.BitmapRasterizer;
                aggsx.UseSubPixelLcdEffect = false;
                sclineRasToBmp.RenderWithColor(clippingProxyGamma, rasterizer, sl, Color.Black);
                rasterizer.ResetGamma(new GammaNone());
                aggsx.UseSubPixelLcdEffect = false;
                //----------------------------------------

                using (VxsTemp.Borrow(out var v1, out var v2))
                    using (VectorToolBox.Borrow(v1, out PathWriter ps))
                    {
                        ps.Clear();
                        ps.MoveTo(_x[0], _y[0]);
                        ps.LineTo(_x[1], _y[1]);
                        ps.LineTo(_x[2], _y[2]);
                        ps.LineTo(_x[0], _y[0]);

                        rasterizer.AddPath(_stroke.MakeVxs(v1, v2));
                    }


                //----------------------------------------
                //Stroke stroke = new Stroke(ps);
                //stroke.Width = 2;
                //rasterizer.AddPath(stroke.MakeVxs(ps.MakeVxs()));

                //----------------------------------------

                sclineRasToBmp.RenderWithColor(clippingProxyNormal, rasterizer, sl, new Color(200, 0, 150, 160));
            }
        }