Fast case PremultiplyAlpha for opaque colors.

This commit is contained in:
RoosterDragon
2015-05-29 19:50:33 +01:00
parent 4c72b0066c
commit 1a89e91630

View File

@@ -114,6 +114,8 @@ namespace OpenRA.Graphics
public static Color PremultiplyAlpha(Color c) public static Color PremultiplyAlpha(Color c)
{ {
if (c.A == byte.MaxValue)
return c;
var a = c.A / 255f; var a = c.A / 255f;
return Color.FromArgb(c.A, (byte)(c.R * a + 0.5f), (byte)(c.G * a + 0.5f), (byte)(c.B * a + 0.5f)); return Color.FromArgb(c.A, (byte)(c.R * a + 0.5f), (byte)(c.G * a + 0.5f), (byte)(c.B * a + 0.5f));
} }