Example #1
0
        public void Apply(PixelFunctionXY pixelFunc, Rectangle region)
        {
            Rectangle rect = ClampRectangle(region, Bounds);

            if (Rectangle.IsAreaNegativeOrEmpty(rect))
            {
                return;
            }

            int sourceOffset = rect.Y * ScanlineSize + rect.X * _bytesPerPixel;

            for (int y = 0; y < rect.Height; y++)
            {
                int lineIndex = sourceOffset + y * ScanlineSize;
                for (int x = 0; x < rect.Width; x++)
                {
                    int   index  = lineIndex + x * _bytesPerPixel;
                    Color result = pixelFunc(new Color(
                                                 _data[index + 0],
                                                 _data[index + 1],
                                                 _data[index + 2],
                                                 _data[index + 3]), rect.X + x, rect.Y + y);
                    _data[index + 0] = result.R;
                    _data[index + 1] = result.G;
                    _data[index + 2] = result.B;
                    _data[index + 3] = result.A;
                }
            }
        }
Example #2
0
 public void Apply(PixelFunctionXY pixelFunc)
 {
     Apply(pixelFunc, Bounds);
 }
Example #3
0
        public void Apply(PixelFunctionXY pixelFunc, Rectangle region)
        {
            Rectangle rect = ClampRectangle(region, Bounds);

            if (Rectangle.IsAreaNegativeOrEmpty(rect))
                return;

            int sourceOffset = rect.Y * ScanlineSize + rect.X * _bytesPerPixel;
            for (int y = 0; y < rect.Height; y++) {
                int lineIndex = sourceOffset + y * ScanlineSize;
                for (int x = 0; x < rect.Width; x++) {
                    int index = lineIndex + x * _bytesPerPixel;
                    Color result = pixelFunc(new Color(
                        _data[index + 0],
                        _data[index + 1],
                        _data[index + 2],
                        _data[index + 3]), rect.X + x, rect.Y + y);
                    _data[index + 0] = result.R;
                    _data[index + 1] = result.G;
                    _data[index + 2] = result.B;
                    _data[index + 3] = result.A;
                }
            }
        }
Example #4
0
 public void Apply(PixelFunctionXY pixelFunc)
 {
     Apply(pixelFunc, Bounds);
 }