Changing color of an image

Hi,

I need help on how to make a simple color change of the image. The result should be the same as using glSetColor(r, g, b) before a texture is written.

Need this for my map editor to be able to specify color for an entire layer.

If there is no easy (and fast) way to do it, is there a way to set the brightness of an image?

int[] srcData = (int[])((DataBufferInt) srcImage.getRaster().getDataBuffer()).getData();

if the image is of type BufferedImage.TYPE_INT_RGB

the ints contain the color channels like 00rrggbb

then just mulitply the color channels by the float values

you could keep two images, the original one and then the one that has a changed color so the original image is kept clean.

There is probaly a better way to do it tho.

Would drawing a translucent rectangle over the image work?

translucent image wouldn’t work as that would also affect layers underneath.

If noone has a better suggestion, I guess I’ll have to implement g666’s method.

Thanx for the help.

edit:

I implemented it almost the way you suggested g666. I made another image and used getRgb(x, y). Modified the value and used setRgb(x, y, color) on the other picture. Works very well.