I have two TIF files, one is background (overlay) and the other is foreground. The following code is currently used for combining two TIFs.
// Background color of foreground image
int w = Color.WHITE.getRGB();
// Fill all pixels which are not background color
for (int i = 0; i < foregroundImage.getWidth(); i++)
{
for (int j = 0; j < foregroundImage.getHeight(); j++)
{
int x = foregroundImage.getRGB(i, j);
if (x != w)
backgroundImage.setRGB(i, j, x);
}
}
Is there any other way that has a better performance to do this?