Color Keying and Bitmap Fonts

I can create bitmap fonts just fine, but I’d like to have bitmap fonts of different colors. In my image file the characters are white, and I want to replace the white color with any color of my choice. The problem is that I don’t even know if there’s a way to do this while maintaining hardware acceleration. I searched some older posts but I found no hardware accelerated versions. Is there a way to do it?

Also, just a side question. In order for images to be accelerated, they must not exceed 65536 bytes. Is there any advantage to making images squares? An image that’s 128x128 vs. 256x64… should I expect any difference in performance? Thanks a lot :slight_smile:

Well, this thread might be interesting:

http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=2D;action=display;num=1091616545;start=5#5

With 1.4+, however, you may look into using a palletized BufferedImage. It won’t be hardware accelerated (unless you copy it into another image after changing the pallette), but it should be more than fast enough for most uses.

Ok, I’ll look into a that… copying it into another image doesn’t sound so bad as I’m not going to be loading fonts that much.

Thanks :slight_smile:

Hmm, I just had a thought. Could I just call bufferedImage.getGraphics() and replace all the white pixels with another color by using drawLine(x, y, x, y)? Would this be an acceptable solution? Or at least be more efficient than copying the entire BufferedImage into another one?

Obviously I couldn’t use this technique for replacing pixels so that they’re transparent, but I don’t even need that.

Don’t tell me if I call getRGB(x, y) my image won’t be accelerated anymore :stuck_out_tongue:

sure you can set the pixels to be transparent, I think… dunno how though :wink: Maybe I’m wrong. Using the getRGB()/setRGB() methods will not make you lose your acceleration. Calling .getDataRaster() will.