Java Utililty Methods Color Alpha

List of utility methods to do Color Alpha

Description

The list of methods to do Color Alpha are organized into topic(s).

Method

ColorpremultiplyAlpha(Color fgColor, Color bgColor)
premultiply Alpha
int r, g, b;
r = fgColor.getRed() * fgColor.getAlpha() + bgColor.getRed() * (255 - fgColor.getAlpha());
g = fgColor.getGreen() * fgColor.getAlpha() + bgColor.getGreen() * (255 - fgColor.getAlpha());
b = fgColor.getBlue() * fgColor.getAlpha() + bgColor.getBlue() * (255 - fgColor.getAlpha());
Color result = new Color(r / 255, g / 255, b / 255);
return result;
ColorsetColorAlpha(Color c, int alpha)
set Color Alpha
if (alpha > 255 || alpha < 0)
    return c;
return new Color(c.getRed(), c.getGreen(), c.getBlue(), alpha);
ColorsetColorAlpha(Color color, int alpha)
Returns the old color with new alpha value.
return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
Colortransparent(final Color color, final int alpha)
transparent
return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
ColortransparentColor(Color color, int alpha)
transparent Color
if (color == null)
    return null;
return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
ColorwashColor(int red, int green, int blue, int alpha, int amountToWash)
wash Color
return new Color(red / amountToWash, green / amountToWash, blue / amountToWash, alpha / amountToWash);