コード例 #1
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.LoadFontAtlasInfo(fs)[0];
            }

            PixelFarm.CpuBlit.MemBitmap actualImg = null;
            using (System.IO.FileStream fs = new System.IO.FileStream(RootDemoPath.Path + @"\a_total.png", System.IO.FileMode.Open))
            {
                actualImg = PixelFarm.CpuBlit.MemBitmap.LoadBitmap(fs);
            }
            _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;
        }
コード例 #2
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;



            //---------------------
        }
コード例 #3
0
ファイル: T404_FontAtlas.cs プロジェクト: dhilip89/PixelFarm
        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;
        }