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(); }
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(); }
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)); }
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); }
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(); }
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(); }