Java Color Brighten modifyBrightness(Color c, float brightness)

Here you can find the source of modifyBrightness(Color c, float brightness)

Description

Modifies an existing brightness level of a color

License

Open Source License

Parameter

Parameter Description
c The color
brightness The brightness

Return

Adjusted color

Declaration

public static Color modifyBrightness(Color c, float brightness) 

Method Source Code


//package com.java2s;
/* Copyright 2012 Yaqiang Wang,
* yaqiang.wang@gmail.com/* w  w  w.ja  v  a  2s . c o  m*/
* 
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or (at
* your option) any later version.
* 
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
* General Public License for more details.
*/

import java.awt.Color;

public class Main {
    /**
     * Modifies an existing brightness level of a color
     *
     * @param c The color
     * @param brightness The brightness
     * @return Adjusted color
     */
    public static Color modifyBrightness(Color c, float brightness) {
        float hsbVals[] = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
        return Color.getHSBColor(hsbVals[0], hsbVals[1], brightness * hsbVals[2]);
    }
}

Related

  1. hsbToRgB(double hue, double sat, double brightness)
  2. HSBtoRGB(float hue, float saturation, float brightness)
  3. HSBtoRGB(float parHue, float parSaturation, float parBrightness)
  4. increaseBrightness(Image image)
  5. makeColorBrighter(Color color)
  6. perceivedBrightness(Color c)
  7. setBrightness(Color color, float brightness)
  8. setBrightness(Color color, float brightness)
  9. setColorBrightness(Color c, double y)