Using the Slick2D Library for Java, I want to know if there is a way to brighten an instance of org.newdawn.slick.Image. I'm willing to use other image-manipulation libraries if need be.
|
|
|
I can imagine a few different ways to do this, but which one is the best will depend on your particular situation. First of all, if it is possible to perform this offline using some image editing software then that would probably give the best result and result in better performance for your application. However, I am guessing that this is not possible in your situation. Now, the easiest and most efficient online solution that I can come up with would be to simply render the image multiple times using additive blend mode. (g.setDrawMode(Graphics.MODE_ADD)). If you need precise control of the brightness you might be able to render the image with a different alpha value as an intermediate step and then use the result to add to your output image. Here is a small example
If this is not enough for your needs then there is always the possibility of performing the brightness changes manually on a per-pixel basis by rendering 1x1 squares of the desired (brighter) color to the resulting image. There is a Color.brighter(scale) method that could be helpful when doing this. Note however that doing this operation pixel by pixel is likely to be very inefficient. Please not however that both of the above methods will just uniformly scale the RGB components of the image. This will result in an image that looks brighter, but in order for the image to retain its colors as perceived by the human eye you should instead increase the perceived brightness or something along those lines. This can for example be done by first converting the colors from RGB space to HSL space, increase the L component by as much as you want. Finally you can convert back to a new and brighter RGB color. Some additional resources on this can be found here: |
|||||
|
