示例#1
0
        protected override void OnInitGLProgram(object sender, EventArgs args)
        {
            int max = Math.Max(this.Width, this.Height);

            canvas2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max);
            painter  = new GLCanvasPainter(canvas2d, max, max);

            //---------------------
            string fontfilename = "d:\\WImageTest\\a_total.xml";
            var    atlasBuilder = new Typography.Rendering.SimpleFontAtlasBuilder();

            fontAtlas = atlasBuilder.LoadFontInfo(fontfilename);

            totalImg = new System.Drawing.Bitmap("d:\\WImageTest\\a_total.png");

            var bmpdata = totalImg.LockBits(new System.Drawing.Rectangle(0, 0, totalImg.Width, totalImg.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, totalImg.PixelFormat);
            var buffer  = new int[totalImg.Width * totalImg.Height];

            System.Runtime.InteropServices.Marshal.Copy(bmpdata.Scan0, buffer, 0, buffer.Length);
            totalImg.UnlockBits(bmpdata);
            var glyph = new Typography.Rendering.GlyphImage(totalImg.Width, totalImg.Height);

            glyph.SetImageBuffer(buffer, false);
            fontAtlas.TotalGlyph = glyph;



            //---------------------
        }
示例#2
0
        protected override void OnReadyForInitGLShaderProgram()
        {
            //---------------------
            var atlasBuilder = new Typography.Rendering.SimpleFontAtlasBuilder();

            fontAtlas = atlasBuilder.LoadFontInfo(RootDemoPath.Path + @"\a_total.xml");


            var actualImg = DemoHelper.LoadImage(RootDemoPath.Path + @"\a_total.png");

            //var bmpdata = totalImg.LockBits(new System.Drawing.Rectangle(0, 0, totalImg.Width, totalImg.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, totalImg.PixelFormat);
            //var buffer = new int[totalImg.Width * totalImg.Height];
            //System.Runtime.InteropServices.Marshal.Copy(bmpdata.Scan0, buffer, 0, buffer.Length);
            //totalImg.UnlockBits(bmpdata);
            var glyph = new Typography.Rendering.GlyphImage(totalImg.Width, totalImg.Height);

            glyph.SetImageBuffer(PixelFarm.Agg.ActualImage.CopyImgBuffer(actualImg), false);
            fontAtlas.TotalGlyph = glyph;
        }
示例#3
0
        protected override void OnReadyForInitGLShaderProgram()
        {
            //---------------------
            var atlasBuilder = new Typography.Rendering.SimpleFontAtlasBuilder();

            using (System.IO.FileStream fs = new System.IO.FileStream(RootDemoPath.Path + @"\a_total.xml", System.IO.FileMode.Open))
            {
                _fontAtlas = atlasBuilder.LoadFontInfo(fs);
            }


            var actualImg = PixelFarm.CpuBlit.MemBitmap.LoadBitmap(RootDemoPath.Path + @"\a_total.png");

            _totalBmp = actualImg;
            //var bmpdata = totalImg.LockBits(new System.Drawing.Rectangle(0, 0, totalImg.Width, totalImg.Height), System.Drawing.Imaging.ImageLockMode.ReadWrite, totalImg.PixelFormat);
            //var buffer = new int[totalImg.Width * totalImg.Height];
            //System.Runtime.InteropServices.Marshal.Copy(bmpdata.Scan0, buffer, 0, buffer.Length);
            //totalImg.UnlockBits(bmpdata);
            var glyph = new Typography.Rendering.GlyphImage(_totalBmp.Width, _totalBmp.Height);

            glyph.SetImageBuffer(PixelFarm.CpuBlit.MemBitmap.CopyImgBuffer(actualImg), false);
            _fontAtlas.TotalGlyph = glyph;
        }