コード例 #1
0
ファイル: IOSBitmap.cs プロジェクト: ebrucucen/MonoAGS
        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));
        }
コード例 #2
0
 public void SetPixels(AGS.API.Color color, List <API.Point> points)
 {
     using (FastBitmap bmp = new FastBitmap(_cgImage))
     {
         foreach (var point in points)
         {
             bmp.SetPixel(point.X, point.Y, color);
         }
         setImage(bmp.GetImage());
     }
 }
コード例 #3
0
ファイル: IOSBitmap.cs プロジェクト: ebrucucen/MonoAGS
        //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());
            }
        }