Java Utililty Methods Color Brighten

List of utility methods to do Color Brighten

Description

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

Method

StringbrighterColor(String hexValue)
brighter Color
return brighterColor(hexValue, 0.1);
Colorbrightness(Color c, float scale)
Adjusts the brightness of the given color.
int r = c.getRed();
int g = c.getGreen();
int b = c.getBlue();
if (r == 0 && g == 0 && b == 0 && scale > 0) {
    r = g = b = Math.min(255, (int) (255 * scale));
} else {
    r = Math.max(0, (int) (r * scale));
    g = Math.max(0, (int) (g * scale));
...
floatbrightness(java.awt.Color c)
brightness
if (c == null)
    return 0;
final int r = c.getRed();
final int g = c.getGreen();
final int b = c.getBlue();
int max = (r > g) ? r : g;
if (b > max)
    max = b;
...
BufferedImagebrightnessToAlpha(Image image, float alpha)
Takes the image brightness and turns it into an alpha-channel.
return brightnessToAlpha(image, (int) (255f * alpha));
ColorchangeBrightness(Color c, int percent)
Construct a Color that is a brighter or darker version of a given color.
if (c == null) {
    return c;
int r = c.getRed();
int g = c.getGreen();
int b = c.getBlue();
float[] hsb = Color.RGBtoHSB(r, g, b, null);
float fraction = (float) percent / 100;
...
ColorchangeColorBrightness(final Color color, final double delta)
change Color Brightness
int r = (int) Math.min(color.getRed() * delta, 255.0);
int g = (int) Math.min(color.getGreen() * delta, 255.0);
int b = (int) Math.min(color.getBlue() * delta, 255.0);
return new Color(r, g, b);
ColorderiveByBrightness(Color original, Color brightnessSource)
Derives a color based on the original color and a brightness source.
float[] hsbvalsOrig = new float[3];
Color.RGBtoHSB(original.getRed(), original.getGreen(), original.getBlue(), hsbvalsOrig);
float[] hsbvalsBrightnessSrc = new float[3];
Color.RGBtoHSB(brightnessSource.getRed(), brightnessSource.getGreen(), brightnessSource.getBlue(),
        hsbvalsBrightnessSrc);
return new Color(
        Color.HSBtoRGB(hsbvalsOrig[0], hsbvalsOrig[1], (hsbvalsBrightnessSrc[2] + hsbvalsOrig[2]) / 2.0f));
ColorderiveColorHSB(Color base, float hue, float saturation, float brightness)
derive Color HSB
float hsb[] = Color.RGBtoHSB(base.getRed(), base.getGreen(), base.getBlue(), null);
hsb[0] += hue;
hsb[1] += saturation;
hsb[2] += brightness;
return Color.getHSBColor(hsb[0] < 0 ? 0 : (hsb[0] > 1 ? 1 : hsb[0]),
        hsb[1] < 0 ? 0 : (hsb[1] > 1 ? 1 : hsb[1]), hsb[2] < 0 ? 0 : (hsb[2] > 1 ? 1 : hsb[2]));
intgetBrightness(Color c)
Calculates the brightness of a color.
double b = c.getRed() * c.getRed() * .241D + c.getGreen() * c.getGreen() * .691D
        + c.getBlue() * c.getBlue() * .068D;
return (int) Math.sqrt(b);
intgetBrightness(Color c)
get Brightness
final int r = c.getRed();
final int g = c.getGreen();
final int b = c.getBlue();
return (int) Math.sqrt(r * r * .241 + g * g * .691 + b * b * .068);