示例#1
0
        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));
        }
示例#2
0
		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);
		}
示例#3
0
 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());
         }
     }
 }
示例#4
0
		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);
					}
				}
			}
		}
示例#5
0
 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);
                 }
             }
         }
     }
 }