// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp { using Drawing; using Drawing.Brushes; using Drawing.Processors; using ImageSharp.PixelFormats; /// /// Extension methods for the type. /// public static partial class ImageExtensions { /// /// Flood fills the image with the specified brush. /// /// The type of the color. /// The image this method extends. /// The details how to fill the region of interest. /// The graphics options. /// The . public static Image Fill(this Image source, IBrush brush, GraphicsOptions options) where TPixel : struct, IPixel { return source.Apply(new FillProcessor(brush, options)); } /// /// Flood fills the image with the specified brush. /// /// The type of the color. /// The image this method extends. /// The details how to fill the region of interest. /// The . public static Image Fill(this Image source, IBrush brush) where TPixel : struct, IPixel { return source.Fill(brush, GraphicsOptions.Default); } /// /// Flood fills the image with the specified color. /// /// The type of the color. /// The image this method extends. /// The color. /// The . public static Image Fill(this Image source, TPixel color) where TPixel : struct, IPixel { return source.Fill(new SolidBrush(color)); } /// /// Flood fills the image with in the region with the specified brush. /// /// The type of the color. /// The image this method extends. /// The brush. /// The region. /// The graphics options. /// The . public static Image Fill(this Image source, IBrush brush, Region region, GraphicsOptions options) where TPixel : struct, IPixel { return source.Apply(new FillRegionProcessor(brush, region, options)); } /// /// Flood fills the image with in the region with the specified brush. /// /// The type of the color. /// The image this method extends. /// The brush. /// The region. /// The . public static Image Fill(this Image source, IBrush brush, Region region) where TPixel : struct, IPixel { return source.Fill(brush, region, GraphicsOptions.Default); } /// /// Flood fills the image with in the region with the specified color. /// /// The type of the color. /// The image this method extends. /// The color. /// The region. /// The options. /// The . public static Image Fill(this Image source, TPixel color, Region region, GraphicsOptions options) where TPixel : struct, IPixel { return source.Fill(new SolidBrush(color), region, options); } /// /// Flood fills the image with in the region with the specified color. /// /// The type of the color. /// The image this method extends. /// The color. /// The region. /// The . public static Image Fill(this Image source, TPixel color, Region region) where TPixel : struct, IPixel { return source.Fill(new SolidBrush(color), region); } } }