Here you can find the source of multiplyColorComponents(int color, float brightnessFactor)
Parameter | Description |
---|---|
color | - original color |
brightnessFactor | - should be positive and <> 1.0F |
public static int multiplyColorComponents(int color, float brightnessFactor)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012 Yancarlo Ramsey and CJ Bowman * Licensed as open source with restrictions. Please see attached LICENSE.txt. ******************************************************************************/ public class Main { private static final int MASKR = 0xFF0000; private static final int MASKG = 0x00FF00; private static final int MASKB = 0x0000FF; /**// w w w .jav a2 s. com * Individually multiply R, G, B color components by scalar value to dim or brighten the color. * Does not check for overflow. Beware when using values over 1.0F. * @param color - original color * @param brightnessFactor - should be positive and <> 1.0F * @return - modified color */ public static int multiplyColorComponents(int color, float brightnessFactor) { return ((int) (brightnessFactor * (color & MASKR)) & MASKR) | ((int) (brightnessFactor * (color & MASKG)) & MASKG) | ((int) (brightnessFactor * (color & MASKB)) & MASKB); } }