My Question: I want to be able to change the brightness of a resource image and have three instances of it as ImageIcons. One at 50% brightness (so darker), ano
The doc says:
The pseudo code for the rescaling operation is as follows:
for each pixel from Source object {
for each band/component of the pixel {
dstElement = (srcElement*scaleFactor) + offset
}
}
It's just a linear transformation on every pixel. The parameters for that transformation are scaleFactor
and offset
. If you want 100% brightness, this transform must be an identity, i.e. dstElement = srcElement
. Setting scaleFactor = 1
and offset = 0
does the trick.
Now suppose you want to make the image darker, at 75% brightness like you say. That amounts to multiplying the pixel values by 0.75. You want: dstElement = 0.75 * srcElement
. So setting scaleFactor = 0.75
and offset = 0
should do the trick. The problem with your values is that they go from 0 to 100, you need to use values between 0 and 1.