/// <summary> /// Creates a cropped view of the source context. /// </summary> public static IReadOnlyPixelRows Crop( this IReadOnlyPixelRowsContext context, int x, int y) { if (context == null) { throw new ArgumentNullException(nameof(context)); } return(Crop(context, new Rectangle(x, y, context.Width - x, context.Height - y))); }
/// <summary> /// Creates a cropped view of the source context. /// </summary> public static IReadOnlyPixelRows Crop( this IReadOnlyPixelRowsContext context, Rectangle sourceRectangle) { if (CheckBounds(context, sourceRectangle)) { return(context); } return(new ReadOnlyCropRows(context.Pixels, sourceRectangle)); }
/// <summary> /// Creates a cropped view of the source context. /// </summary> public static IReadOnlyPixelRows <TPixel> Crop <TPixel>( this IReadOnlyPixelRowsContext <TPixel> context, int x, int y) where TPixel : unmanaged, IPixel { if (context == null) { throw new ArgumentNullException(nameof(context)); } return(Crop(context, new Rectangle(x, y, context.Width - x, context.Height - y))); }
/// <summary> /// Creates a cropped view of the source context. /// </summary> public static IReadOnlyPixelRows <TPixel> Crop <TPixel>( this IReadOnlyPixelRowsContext <TPixel> context, Rectangle sourceRectangle) where TPixel : unmanaged, IPixel { if (CheckBounds(context, sourceRectangle)) { return(context); } return(new ReadOnlyCropRows <TPixel>(context.Pixels, sourceRectangle)); }
internal static bool CheckBounds(this IReadOnlyPixelRowsContext context, Rectangle sourceRectangle) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (context.Pixels.GetBounds() == sourceRectangle) { return(true); } ImagingArgumentGuard.AssertRectangleInSource(context, sourceRectangle, nameof(sourceRectangle)); return(false); }
/// <summary> /// Creates a cropped view of the source context. /// </summary> public static IReadOnlyPixelRows <TPixel> Crop <TPixel>( this IReadOnlyPixelRowsContext <TPixel> context, int x, int y, int width, int height) where TPixel : unmanaged, IPixel { return(Crop(context, new Rectangle(x, y, width, height))); }
/// <summary> /// Creates a cropped view of the source context. /// </summary> public static IReadOnlyPixelRows Crop( this IReadOnlyPixelRowsContext context, int x, int y, int width, int height) { return(Crop(context, new Rectangle(x, y, width, height))); }