diff --git a/src/ImageProcessor/Colors/Color.cs b/src/ImageProcessor/Colors/Color.cs index af1383e0a..e2c6acf21 100644 --- a/src/ImageProcessor/Colors/Color.cs +++ b/src/ImageProcessor/Colors/Color.cs @@ -8,7 +8,6 @@ namespace ImageProcessor using System; using System.ComponentModel; using System.Numerics; - using System.Runtime.CompilerServices; /// /// Represents a four-component color using red, green, blue, and alpha data. @@ -508,6 +507,34 @@ namespace ImageProcessor return new Color(r, g, b, gamma.A); } + /// + /// Converts a non-premultipled alpha to a + /// that contains premultiplied alpha. + /// + /// The red component of this . + /// The green component of this . + /// The blue component of this . + /// The alpha component of this . + /// The . + public static Color FromNonPremultiplied(float r, float g, float b, float a) + { + return new Color(r * a, g * a, b * a, a); + } + + /// + /// Converts a premultipled alpha to a + /// that contains non-premultiplied alpha. + /// + /// The red component of this . + /// The green component of this . + /// The blue component of this . + /// The alpha component of this . + /// The . + public static Color ToNonPremultiplied(float r, float g, float b, float a) + { + return new Color(r / a, g / a, b / a, a); + } + /// /// Gets a representation for this . ///