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; UIImage output; using (FastBitmap inBmp = new FastBitmap(_cgImage)) { using (FastBitmap outBmp = new FastBitmap(Width, Height)) { for (int y = 0; y < Height; y++) { int bitmapY = Height - y - 1; for (int x = 0; x < Width; x++) { var color = inBmp.GetPixel(x, bitmapY); byte alpha = area.IsInArea(new AGS.API.PointF(x, y)) ? color.A : zero; outBmp.SetPixel(x, bitmapY, Color.FromRgba(color.R, color.G, color.B, alpha)); } } output = outBmp.GetImage(); } } return(new IOSBitmap(output, _graphics)); }
public Color GetPixel(int x, int y) { using (FastBitmap bitmap = new FastBitmap(_cgImage)) { return(bitmap.GetPixel(x, y)); } }
//http://stackoverflow.com/questions/633722/how-to-make-one-color-transparent-on-a-uiimage public void MakeTransparent(Color color) { var transparent = Colors.Transparent; using (FastBitmap fastBitmap = new FastBitmap(_cgImage)) { for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { if (fastBitmap.GetPixel(x, y).Equals(color)) { fastBitmap.SetPixel(x, y, transparent); } } } setImage(fastBitmap.GetImage()); } }