Pinta.ImageManipulation.Utility.GetRegionBounds C# (CSharp) Method

GetRegionBounds() public static method

Allows you to find the bounding box for a "region" that is described as an array of bounding boxes.
public static GetRegionBounds ( Rectangle rects, int startIndex, int length ) : Rectangle
rects Rectangle
startIndex int
length int
return Rectangle
		public static Rectangle GetRegionBounds (Rectangle[] rects, int startIndex, int length)
		{
			if (rects.Length == 0) {
				return Rectangle.Empty;
			}

			int left = rects[startIndex].Left;
			int top = rects[startIndex].Top;
			int right = rects[startIndex].Right;
			int bottom = rects[startIndex].Bottom;

			for (int i = startIndex + 1; i < startIndex + length; ++i) {
				Rectangle rect = rects[i];

				if (rect.Left < left) {
					left = rect.Left;
				}

				if (rect.Top < top) {
					top = rect.Top;
				}

				if (rect.Right > right) {
					right = rect.Right;
				}

				if (rect.Bottom > bottom) {
					bottom = rect.Bottom;
				}
			}

			return Rectangle.FromLTRB (left, top, right, bottom);
		}