Example #1
0
        static void DrawLion(PixelFarm.Agg.CanvasPainter p, PixelFarm.Agg.SpriteShape shape, PixelFarm.Agg.VertexStore myvxs)
        {
            int j = shape.NumPaths;

            int[]   pathList = shape.PathIndexList;
            Color[] colors   = shape.Colors;
            for (int i = 0; i < j; ++i)
            {
                p.FillColor = colors[i];
                p.Fill(new PixelFarm.Agg.VertexStoreSnap(myvxs, pathList[i]));
            }
        }
Example #2
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);
            }
        }
Example #3
0
        void TestLoadLionFromBinaryFile()
        {
            System.Diagnostics.Debugger.Break();
            //test load raw buffer
            using (var fs = new System.IO.FileStream("..\\lion_stream.bin", System.IO.FileMode.Open))
            {
                var reader     = new System.IO.BinaryReader(fs);
                var lionShape2 = new PixelFarm.Agg.SpriteShape();

                PixelFarm.Agg.VertexSource.PathWriter path;
                PixelFarm.Agg.ColorRGBA[]             colors;
                int[] pathIndexList;
                //1. path and command
                PixelFarm.Agg.VertexSource.dbugVertexSourceIO.ReadPathDataFromStream(
                    reader, out path
                    );
                //2. colors
                PixelFarm.Agg.VertexSource.dbugVertexSourceIO.ReadColorDataFromStream(
                    reader, out colors
                    );
                //3. path indice
                int npaths;
                PixelFarm.Agg.VertexSource.dbugVertexSourceIO.ReadPathIndexListFromStream(
                    reader, out npaths, out pathIndexList
                    );

                //------------------------------
                SpriteShape.UnsafeDirectSetData(lionShape2,
                                                npaths,
                                                path, colors, pathIndexList);
                //---------------------------------

                fs.Close();

                this.lionShape = lionShape2;
            }
        }