public IBitmap ApplyArea(IArea area) { //todo: performance can be improved by only creating a bitmap the size of the area, and not the entire background. //This will require to change the rendering as well to offset the location byte zero = (byte)0; Bitmap output = Bitmap.CreateBitmap(Width, Height, Bitmap.Config.Argb8888); using (FastBitmap inBmp = new FastBitmap(_bitmap)) { using (FastBitmap outBmp = new FastBitmap(output, true)) { for (int y = 0; y < Height; y++) { int bitmapY = Height - y - 1; for (int x = 0; x < Width; x++) { global::Android.Graphics.Color color = inBmp.GetPixel(x, bitmapY); byte alpha = area.IsInArea(new AGS.API.PointF(x, y)) ? color.A : zero; outBmp.SetPixel(x, bitmapY, new global::Android.Graphics.Color(color.R, color.G, color.B, alpha)); } } } } return(new AndroidBitmap(output, _graphics)); }
public IBitmap ApplyArea(IArea area) { //todo: performance can be improved by only creating a bitmap the size of the area, and not the entire background. //This will require to change the rendering as well to offset the location byte zero = (byte)0; Bitmap output = Bitmap.CreateBitmap(Width, Height, Bitmap.Config.Argb8888); using (FastBitmap inBmp = new FastBitmap (_bitmap)) { using (FastBitmap outBmp = new FastBitmap (output, true)) { for (int y = 0; y < Height; y++) { int bitmapY = Height - y - 1; for (int x = 0; x < Width; x++) { global::Android.Graphics.Color color = inBmp.GetPixel(x, bitmapY); byte alpha = area.IsInArea(new AGS.API.PointF(x, y)) ? color.A : zero; outBmp.SetPixel(x, bitmapY, new global::Android.Graphics.Color(color.R, color.G, color.B, alpha)); } } } } return new AndroidBitmap(output, _graphics); }
public void SetPixels(AGS.API.Color color, List <API.Point> points) { using (FastBitmap bmp = new FastBitmap(_bitmap)) { foreach (var point in points) { bmp.SetPixel(point.X, point.Y, color.Convert()); } } }
public void MakeTransparent(AGS.API.Color color) { global::Android.Graphics.Color c = new global::Android.Graphics.Color(color.R, color.G, color.B, color.A); global::Android.Graphics.Color transparent = global::Android.Graphics.Color.Transparent; using (FastBitmap fastBitmap = new FastBitmap (_bitmap)) { for (int x = 0; x < _bitmap.Width; x++) { for (int y = 0; y < _bitmap.Height; y++) { if (fastBitmap.GetPixel(x, y) == c) fastBitmap.SetPixel(x, y, c); } } } }
public void MakeTransparent(AGS.API.Color color) { global::Android.Graphics.Color c = new global::Android.Graphics.Color(color.R, color.G, color.B, color.A); global::Android.Graphics.Color transparent = global::Android.Graphics.Color.Transparent; using (FastBitmap fastBitmap = new FastBitmap(_bitmap)) { for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { if (fastBitmap.GetPixel(x, y) == c) { fastBitmap.SetPixel(x, y, transparent); } } } } }