/// <summary> /// Creates a cropped view of the source context. /// </summary> public static IPixelBuffer Crop(this IPixelBufferContext 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 IPixelBuffer <TPixel> Crop <TPixel>( this IPixelBufferContext <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 IPixelBuffer <TPixel> Crop <TPixel>( this IPixelBufferContext <TPixel> context, Rectangle sourceRectangle) where TPixel : unmanaged, IPixel { if (context.CheckBounds(sourceRectangle)) { return(context); } return(new CropBuffer <TPixel>(context.Pixels, sourceRectangle)); }
/// <summary> /// Creates a cropped view of the source context. /// </summary> public static IPixelBuffer Crop(this IPixelBufferContext context, Rectangle sourceRectangle) { return(new CropBuffer(context?.Pixels, sourceRectangle)); }
/// <summary> /// Creates a cropped view of the source context. /// </summary> public static IPixelBuffer <TPixel> Crop <TPixel>( this IPixelBufferContext <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 IPixelBuffer Crop(this IPixelBufferContext context, int x, int y, int width, int height) { return(Crop(context, new Rectangle(x, y, width, height))); }