Treefrog.Framework.Imaging.Rectangle.IsAreaNegativeOrEmpty C# (CSharp) Method

IsAreaNegativeOrEmpty() public static method

public static IsAreaNegativeOrEmpty ( Rectangle rect ) : bool
rect Rectangle
return bool
        public static bool IsAreaNegativeOrEmpty(Rectangle rect)
        {
            return rect.Width <= 0 || rect.Height <= 0;
        }

Usage Example

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;
                }
            }
        }
All Usage Examples Of Treefrog.Framework.Imaging.Rectangle::IsAreaNegativeOrEmpty