Esempio n. 1
0
        static void UpdateViewContent(FormRenderUpdateEventArgs formRenderUpdateEventArgs)
        {
            needUpdateContent = false;
            //1. create platform bitmap
            // create the surface
            int w = 800;
            int h = 600;

            if (myImg == null)
            {
                myImg = new TestGlfw.MyNativeRGBA32BitsImage(w, h);
            }


            int testNo = 2;

            if (testNo == 0)
            {
                //test1
                // create the surface
                var info = new SKImageInfo(w, h, SKImageInfo.PlatformColorType, SKAlphaType.Premul);
                using (var surface = SKSurface.Create(info, myImg.Scan0, myImg.Stride))
                {
                    // start drawing
                    SKCanvas canvas = surface.Canvas;
                    DrawWithSkia(canvas);
                    surface.Canvas.Flush();
                }
                glBmp = new PixelFarm.DrawingGL.GLBitmap(w, h, myImg.Scan0);
            }
            else
            {
                ////---------------------------------------------------------------------------------------
                //test2
                var lionShape = new PixelFarm.Agg.SpriteShape();
                lionShape.ParseLion();
                var lionBounds = lionShape.Bounds;
                //-------------
                var aggImage   = new PixelFarm.Agg.ActualImage((int)lionBounds.Width, (int)lionBounds.Height, PixelFarm.Agg.PixelFormat.ARGB32);
                var imgGfx2d   = new PixelFarm.Agg.ImageGraphics2D(aggImage);
                var aggPainter = new PixelFarm.Agg.AggCanvasPainter(imgGfx2d);
                DrawLion(aggPainter, lionShape, lionShape.Path.Vxs);
                //-------------



                //convert affImage to texture
                glBmp = LoadTexture(aggImage);
            }
        }
Esempio n. 2
0
 public override void Draw(CanvasPainter p)
 {
     //this specific for agg
     if (p is PixelFarm.Agg.AggCanvasPainter)
     {
         PixelFarm.Agg.AggCanvasPainter p2 = (PixelFarm.Agg.AggCanvasPainter)p;
         Graphics2D gx         = p2.Graphics;
         var        childImage = ImageHelper.CreateChildImage(gx.DestImage, gx.GetClippingRect());
         //IRecieveBlenderByte rasterBlender = new BlenderBGRA();
         var            rasterGamma         = new ChildImage(childImage, new PixelBlenderGammaBGRA(this.GammaValue));
         ClipProxyImage clippingProxyNormal = new ClipProxyImage(childImage);
         ClipProxyImage clippingProxyGamma  = new ClipProxyImage(rasterGamma);
         clippingProxyNormal.Clear(Color.White);
         var rasterizer     = gx.ScanlineRasterizer;
         var sl             = new ScanlineUnpacked8();
         int size_mul       = this.PixelSize;
         var sclineToBmpEn2 = new CustomScanlineRasToBmp_EnlargedV2(size_mul, gx.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 = gx.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]);
         var v1 = GetFreeVxs();
         rasterizer.AddPath((new Stroke(2)).MakeVxs(ps.Vxs, v1));
         sclineRasToBmp.RenderWithColor(clippingProxyNormal, rasterizer, sl, new Color(200, 0, 150, 160));
         ReleaseVxs(ref v1);
     }
 }