Suppose there is an arbitrary RGB color, and this color is 100% brightness, respectively, 0% is 0.0.0 (black). Tell me the formula for calculating the color from the reference, indicating the brightness as a percentage.

There is a thought that everything is easier than I think:

double adjust = 0.5; // 0.1 - 10%, 1 - 100% int r = (int) (r1 * adjust); int g = (int) (g1 * adjust); int b = (int) (b1 * adjust); 

Is it so?

  • Is the brightness in HSV described? So you need to translate RGB to HSV, change the brightness and do the reverse conversion - gil9red

1 answer 1

You probably should use a different color model. Convert your color to RGB -> HSB, then change the brightness / saturation without changing the color tone.

HSB designations:

  • H - color tone (hue)
  • S - saturation
  • B - brightness (brightness)