コード例 #1
0
        public void DrawImage(Image image, Rectangle to, int fromx, int fromy, int fromw, int fromh, GraphicsUnit gu, ImageAttributes ia)
        {
            APaint.Flags = (Android.Graphics.PaintFlags) 0;
            var sa = new Android.Graphics.Rect(fromx, fromy, fromx + fromw, fromy + fromh);
            var da = to.ToA();

            Android.Graphics.Paint p = null;
            Android.Graphics.ColorMatrixColorFilter cmf = null;
            if (ia != null && ia.GetColorMatrix() != null)
            {
                p = new Android.Graphics.Paint(APaint);
                var     values = ia.GetColorMatrix().Matrix;
                float[] v2     = values[0].Concat(values[1]).Concat(values[2]).Concat(values[3]).ToArray();
                cmf = new Android.Graphics.ColorMatrixColorFilter(v2);
                p.SetColorFilter(cmf);
            }
            ACanvas.DrawBitmap((image as Bitmap).ABitmap, sa, da, p == null ? APaint : p);
            if (p != null)
            {
                p.Dispose();
            }
            if (cmf != null)
            {
                cmf.Dispose();
            }
            da.Dispose();
            sa.Dispose();
        }
コード例 #2
0
        public void DrawImage(Image image, int x, int y, Rectangle source, GraphicsUnit gu)
        {
            APaint.Flags = (Android.Graphics.PaintFlags) 0;
            var sa = source.ToA();
            var da = new Android.Graphics.Rect(x, y, x + source.Width, y + source.Height);

            ACanvas.DrawBitmap((image as Bitmap).ABitmap, sa, da, APaint);
            da.Dispose();
            sa.Dispose();
        }
コード例 #3
0
        public Size MeasureString(string text, Font font)
        {
            APaint.TextSize = APixels(font.Size);
            APaint.SetTypeface(Android.Graphics.Typeface.Default);//TODO
            APaint.SetStyle(Android.Graphics.Paint.Style.Stroke);
            var fm     = APaint.GetFontMetricsInt();
            var bounds = new Android.Graphics.Rect();

            APaint.GetTextBounds(text, 0, text.Length, bounds);
            var width  = bounds.Width();
            var height = -fm.Top + fm.Bottom;

            fm.Dispose();
            bounds.Dispose();
            return(new Size(width, height));
        }
コード例 #4
0
ファイル: FastGraphics.cs プロジェクト: jkl83/AndroidDrawing
 public Size MeasureString(string text, Font font)
 {
     APaint.TextSize = APixels(font.Size);
     APaint.SetTypeface(Android.Graphics.Typeface.Default);//TODO
     APaint.SetStyle(Android.Graphics.Paint.Style.Stroke);
     var fm = APaint.GetFontMetricsInt();
     var bounds = new Android.Graphics.Rect();
     APaint.GetTextBounds(text, 0, text.Length, bounds);
     var width = bounds.Width();
     var height = -fm.Top + fm.Bottom;
     fm.Dispose();
     bounds.Dispose();
     return new Size(width, height);
 }
コード例 #5
0
ファイル: FastGraphics.cs プロジェクト: jkl83/AndroidDrawing
        public void DrawImage(Image image, Rectangle to, int fromx, int fromy, int fromw, int fromh, GraphicsUnit gu, ImageAttributes ia)
        {
            Flush();

            APaint.Flags = (Android.Graphics.PaintFlags)0;
            var sa = new Android.Graphics.Rect(fromx, fromy, fromx+fromw, fromy+fromh);
            var da = to.ToA();

            Android.Graphics.Paint p = null;
            Android.Graphics.ColorMatrixColorFilter cmf = null;
            if (ia != null && ia.GetColorMatrix() != null){
                p = new Android.Graphics.Paint(APaint);
                var values = ia.GetColorMatrix().Matrix;
                float[] v2 = values[0].Concat(values[1]).Concat(values[2]).Concat(values[3]).ToArray();
                cmf = new Android.Graphics.ColorMatrixColorFilter(v2);
                p.SetColorFilter(cmf);
            }
            ACanvas.DrawBitmap((image as Bitmap).ABitmap, sa, da, p == null ? APaint : p);
            if (p != null) p.Dispose();
            if (cmf != null) cmf.Dispose();
            da.Dispose();
            sa.Dispose();
        }
コード例 #6
0
ファイル: FastGraphics.cs プロジェクト: jkl83/AndroidDrawing
 public void DrawImage(Image image, int x, int y, Rectangle source, GraphicsUnit gu)
 {
     Flush();
     APaint.Flags = (Android.Graphics.PaintFlags)0;
     var sa = source.ToA();
     var da = new Android.Graphics.Rect(x,y, x+source.Width, y+source.Height);
     ACanvas.DrawBitmap((image as Bitmap).ABitmap, sa, da, APaint);
     da.Dispose();
     sa.Dispose();
 }