// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageProcessorCore { using System; using Processors; /// /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Pixelates an image with the given pixel size. /// /// The pixel format. /// The packed format. uint, long, float. /// The image this method extends. /// The size of the pixels. /// The . public static Image Pixelate(this Image source, int size = 4) where TColor : IPackedVector where TPacked : struct { return Pixelate(source, size, source.Bounds); } /// /// Pixelates an image with the given pixel size. /// /// The pixel format. /// The packed format. uint, long, float. /// The image this method extends. /// The size of the pixels. /// /// The structure that specifies the portion of the image object to alter. /// /// The . public static Image Pixelate(this Image source, int size, Rectangle rectangle) where TColor : IPackedVector where TPacked : struct { if (size <= 0 || size > source.Height || size > source.Width) { throw new ArgumentOutOfRangeException(nameof(size)); } return source.Process(rectangle, new PixelateProcessor(size)); } } }