If you load your collision map as a BufferedImage (using the ImageIO class) you can then call ‘getRGB( x, y )’ on it to return the colour value at that given location. This is in the form of 4 bytes packed into an int in the format of alpha, red, green and blue. To get these out you can bit-shift and then bit-and the value with 0xff; but if your not used to using bit-shifting then you can simply wrap the int inside a new Color object (which can take a single int in it’s constructor). You can then use the Color object to get out the components.
I’d imagine getRGB is simply performing a direct array lookup after jumping through a couple of functions, which should be cheap. However incase it is slow you can also get out all pixels in a giant array using the other ‘getRGB’ method and then just throw away your image. That should be something like:
BufferedImage img = ImageIO.read( new File("my_collisions.png") );
int[] pixels img.getRGB( 0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth() );
// some code later...
// find the pixel at the collision x,y
int pixel = pixels[x + y*img.getWidth()];
// get out the red
int red = (pixel >> 16) & 0xff;
if ( red > 200 ) {
// handle collision
} else {
// no collision
}
Note that the above is untested.
Once you have the components you can state if there is a collision if red is equal to 255, otherwise there isn’t. Two tips; make sure you don’t use jpegs (as they will alter the values stored) and don’t check for exact values. For example rather then checking if red is 255, check if red is greater then 250 or 200. This makes the maps a bit easier to work with. Your already using a PNG and this is very good because it’s a format that is excellent at compressing a large blocks of the same colour.