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.


1 Answer 1


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

dark = new Image("media/dark.jpeg");

bright = new Image(dark.getWidth(), dark.getHeight());
Graphics g = bright.getGraphics();
g.drawImage(dark, 0.0f, 0.0f);
g.drawImage(dark, 0.0f, 0.0f);
g.drawImage(dark, 0.0f, 0.0f); // The more times you call this the brighter the image will be. 

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:

  • \$\begingroup\$ Hi Jiddo. I tried the sample code you provided and I'm met with a blank screen with audio still working. The stack trace spams INFO:Offscreen Buffers FBO=true PBUFFER=true PBUFFERRT=false. Any idea what is going on? \$\endgroup\$ Commented Jul 21, 2012 at 16:22
  • \$\begingroup\$ Could you be more specific as to how you used the code? The example code itself doesn't actually render anything. It only creates a new image object "bright" which is brighter then the original. I'm not sure why it spams that. Are you perhaps creating new image objects every frame? You might wanna create a new question for this. \$\endgroup\$
    – Jiddo
    Commented Jul 26, 2012 at 11:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .