Here you can find the source of brighten(Color color)
Parameter | Description |
---|---|
color | a parameter |
public static Color brighten(Color color)
//package com.java2s; /* /*from w ww . ja v a 2 s . c o m*/ Created on Mar 4, 2005 The Bungee View applet lets you search, browse, and data-mine an image collection. Copyright (C) 2006 Mark Derthick This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See gpl.html. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. You may also contact the author at mad@cs.cmu.edu, or at Mark Derthick Carnegie-Mellon University Human-Computer Interaction Institute Pittsburgh, PA 15213 */ import java.awt.Color; public class Main { private static final float colorComponentChangeFactor = 2.0f; /** * @param color * @return Increases brightness. If factor < 1 it will get dimmer. */ public static Color brighten(Color color) { return brighten(color, colorComponentChangeFactor); } /** * @param color * @param factor * @return Multiplies brightness by factor. If factor < 1 it will get * dimmer. */ public static Color brighten(Color color, float factor) { if (factor <= 0.0) factor = colorComponentChangeFactor; float[] hsb = getHSBcomponents(color); return Color.getHSBColor(hsb[0], hsb[1], Math.min(1.0f, hsb[2] * factor)); } public static float[] getHSBcomponents(Color color) { float[] result = new float[3]; Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), result); return result; } public static Color getHSBColor(float h, float s, float b, float alpha) { Color c = Color.getHSBColor(h, s, b); return new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) (alpha * 255 + 0.5)); } }