Looking at a previous response to a similar question to this, I developed this code:
public static BufferedImage getImage(String imagefile) {
BufferedImage image = null;
try {
image = javax.imageio.ImageIO.read(new java.io.File(imagefile));
int trans = image.getRGB(0,0);
final int width = image.getWidth();
int[] imgData = new int[width];
for (int y = 0; y < image.getHeight(); y++) {
// fetch a line of data from each image
image.getRGB(0, y, width, 1, imgData, 0, 1);
for (int x = 0; x < width; x++)
if (imgData[x] == trans)
imgData[x] |= 0xFF000000;
// replace the data
image.setRGB(0, y, width, 1, imgData, 0, 1);
}
} catch (Exception e) {
e.printStackTrace();
}
return image;
}
In it, the idea is to take the upper left hand color and apply transparency on all pixels that matches that color in the image. The problem is when I do
g.drawImage(img, across, down, cells, cells, null);
I still get the color that is suppose to be transparent. Am I forgetting a step somewhere?
I used a bmp file to do the test.
Thank you for your time.