Exemplo n.º 1
0
 public void DrawString(char[] text, int startAt, int len, double x, double y)
 {
     if (this.UseSubPixelRendering)
     {
         //1. clear prev drawing result
         _aggPainter.Clear(Drawing.Color.FromArgb(0, 0, 0, 0));
         //aggPainter.Clear(Drawing.Color.White);
         //aggPainter.Clear(Drawing.Color.FromArgb(0, 0, 0, 0));
         //2. print text span into Agg Canvas
         textPrinter.DrawString(text, startAt, len, 0, 0);
         //3.copy to gl bitmap
         byte[] buffer = PixelFarm.Agg.ActualImage.GetBuffer(actualImage);
         //------------------------------------------------------
         GLBitmap glBmp = new GLBitmap(bmpWidth, bmpHeight, buffer, true);
         glBmp.IsInvert = false;
         //TODO: review font height
         canvas.DrawGlyphImageWithSubPixelRenderingTechnique(glBmp, (float)x, (float)y + 40);
         glBmp.Dispose();
     }
     else
     {
         //1. clear prev drawing result
         _aggPainter.Clear(Drawing.Color.FromArgb(0, 0, 0, 0));
         //2. print text span into Agg Canvas
         textPrinter.DrawString(text, startAt, len, 0, 0);
         //3.copy to gl bitmap
         byte[] buffer = PixelFarm.Agg.ActualImage.GetBuffer(actualImage);
         //------------------------------------------------------
         GLBitmap glBmp = new GLBitmap(bmpWidth, bmpHeight, buffer, true);
         glBmp.IsInvert = false;
         //TODO: review font height
         canvas.DrawGlyphImage(glBmp, (float)x, (float)y + 40);
         glBmp.Dispose();
     }
 }
        public void DrawString(char[] text, int startAt, int len, double x, double y)
        {
            if (this.UseSubPixelRendering)
            {
                //1. clear prev drawing result
                _aggPainter.Clear(Drawing.Color.FromArgb(0, 0, 0, 0));
                //aggPainter.Clear(Drawing.Color.White);
                //aggPainter.Clear(Drawing.Color.FromArgb(0, 0, 0, 0));
                //2. print text span into Agg Canvas
                _vxsTextPrinter.DrawString(text, startAt, len, 0, 0);
                //3.copy to gl bitmap
                //byte[] buffer = PixelFarm.Agg.ActualImage.GetBuffer(_actualImage);
                //------------------------------------------------------
                GLBitmap glBmp = new GLBitmap(_actualImage);
                glBmp.IsInvert = false;
                //TODO: review font height
                if (StartDrawOnLeftTop)
                {
                    y -= _vxsTextPrinter.FontLineSpacingPx;
                }
                _glsx.DrawGlyphImageWithSubPixelRenderingTechnique(glBmp, (float)x, (float)y);
                glBmp.Dispose();
            }
            else
            {
                //1. clear prev drawing result
                _aggPainter.Clear(Drawing.Color.White);
                _aggPainter.StrokeColor = Color.Black;

                //2. print text span into Agg Canvas
                _vxsTextPrinter.StartDrawOnLeftTop = false;

                float dyOffset = _vxsTextPrinter.FontDescedingPx;
                _vxsTextPrinter.DrawString(text, startAt, len, 0, -dyOffset);
                //------------------------------------------------------
                //debug save image from agg's buffer
#if DEBUG
                //actualImage.dbugSaveToPngFile("d:\\WImageTest\\aa1.png");
#endif
                //------------------------------------------------------

                //3.copy to gl bitmap
                //byte[] buffer = PixelFarm.Agg.ActualImage.GetBuffer(_actualImage);
                //------------------------------------------------------
                //debug save image from agg's buffer

                //------------------------------------------------------
                //GLBitmap glBmp = new GLBitmap(bmpWidth, bmpHeight, buffer, true);
                GLBitmap glBmp = new GLBitmap(_actualImage);
                glBmp.IsInvert = false;
                //TODO: review font height
                //if (StartDrawOnLeftTop)
                //{
                y += _vxsTextPrinter.FontLineSpacingPx;
                //}
                _glsx.DrawGlyphImage(glBmp, (float)x, (float)y + dyOffset);
                glBmp.Dispose();
            }
        }
Exemplo n.º 3
0
        public void DrawString(char[] text, double x, double y)
        {
            aggPainter.Clear(Drawing.Color.White);
            //draw text
            textPrinter.DrawString(text, 0, 18);

            byte[] buffer = PixelFarm.Agg.ActualImage.GetBuffer(actualImage);
            //------------------------------------------------------
            GLBitmap glBmp = new GLBitmap(bmpWidth, bmpHeight, buffer, true);

            bool isYFliped = canvas.FlipY;

            if (isYFliped)
            {
                canvas.DrawImage(glBmp, (float)x, (float)y);
            }
            else
            {
                canvas.FlipY = true;
                canvas.DrawImage(glBmp, (float)x, (float)y);
                canvas.FlipY = false;
            }
            glBmp.Dispose();
        }