Пример #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 = new Bitmap(Width, Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            using (FastBitmap inBmp = new FastBitmap(_bitmap, ImageLockMode.ReadOnly))
            {
                using (FastBitmap outBmp = new FastBitmap(output, ImageLockMode.WriteOnly, true))
                {
                    for (int y = 0; y < Height; y++)
                    {
                        int bitmapY = Height - y - 1;
                        for (int x = 0; x < Width; x++)
                        {
                            System.Drawing.Color color = inBmp.GetPixel(x, bitmapY);
                            byte alpha = area.IsInArea(new AGS.API.PointF(x, y)) ? color.A : zero;
                            outBmp.SetPixel(x, bitmapY, System.Drawing.Color.FromArgb(alpha, color));
                        }
                    }
                }
            }

            return(new DesktopBitmap(output, _graphics));
        }
Пример #2
0
 public void SetPixels(AGS.API.Color color, List <API.Point> points)
 {
     using (FastBitmap bmp = new FastBitmap(_bitmap, ImageLockMode.WriteOnly))
     {
         foreach (var point in points)
         {
             bmp.SetPixel(point.X, point.Y, color.Convert());
         }
     }
 }