Original Post
Hey everyone I was wondering if you could help me out with a little issue. I am designing a 2D space adventure game and I decided that I could really add to the overall effect by adding light sources to which ships and interstellar objects would be reflective.
Currently I draw the ships image, then I draw the bumpMapped image (the image with light and shadows cast on it; no color) over top of the ships actual image. I set the transparency of the bumpMapped image to a level were it doest fully cover the ships image. What I would like to do instead, is to draw a single rendered image with the combined rgb values of the bumpMapped image and the ships actual image. So for each pixel the, red, green, blue and alpha values of the bumpMapped and ship Image would be summed and averaged, giving the concatenation of the two. The code I have written for this is, this code is quite sluggish, and so really my question is. What is the most efficient way of adding two RGB values together??
Currently I draw the ships image, then I draw the bumpMapped image (the image with light and shadows cast on it; no color) over top of the ships actual image. I set the transparency of the bumpMapped image to a level were it doest fully cover the ships image. What I would like to do instead, is to draw a single rendered image with the combined rgb values of the bumpMapped image and the ships actual image. So for each pixel the, red, green, blue and alpha values of the bumpMapped and ship Image would be summed and averaged, giving the concatenation of the two. The code I have written for this is,
a = (((testImg.getRGB(x, y) >>> 24) & 0xFF) + ((environmentMap[nX][nY] >>> 24) & 0xFF));
r = (((testImg.getRGB(x, y) >>> 16) & 0xFF) + ((environmentMap[nX][nY] >>> 16) & 0xFF));
g = (((testImg.getRGB(x, y) >>> 8) & 0xFF) + ((environmentMap[nX][nY] >>> 8) & 0xFF));
b = (((testImg.getRGB(x, y) >>> 0) & 0xFF) + ((environmentMap[nX][nY] >>> 0) & 0xFF));
bumpImg.setRGB(x, y, (new Color(r, g, b, a)).getRGB());