Contents Previous Next

## 9.20 Adjusting brightness and contrast for images and backgrounds

The following section only applies to palette images. This means it wont work on true-color images.

It is often desirable to have a background image look a little bit "washed" out so it doesn't take the concentration away from the actual graph. There are basically two ways of accomplish this

1. Prepare the image with an external images editor to adjust the level of brightness and contrasty to a desirable level
2. Use JpGraph:s built in adjustment for contrast, brightness and color saturation.

To adjust the background image call The levels for both brightness and contrast are real numbers in the range [-1, 1] You can choose to adjust for example just the background image or you might also choose to adjust the whole image. To change the background image just use the method Graph::AdjBackgroundImage() to specify a suitable value. Let's show some example on what we can do with this. The following example have been generated by using the small utility "adjimg.php" which you can find in the "utils/" directory.

Brightness=0, contrast=0, saturation = -1 (Original image)

Brightness=0, contrast=0, saturation = -1 (Black & White image)

Brightness=0.3, contrast=-0.3, saturation=0

Brightness=0.4, contrast=-0.7, saturation=0

Brightness=0.4, contrast=-0.7, saturation=-1

Brightness=0, contrast=0, saturation=1

Contents Previous Next