fps problem

Hi,

when I use this transparent gif: http://kurve.knot.be/gui2.gif
as the background for my game, I get an fps of 75, which is ok because I lock my fps on 75.

However, when I use this transparent gif: http://kurve.knot.be/gui1.gif as background, I get only 30-35 fps. Why could this be? This image us even smaller than the previous (5kb vs 53kb)

???

Offcourse you could say: use the first image, the other one sucks anyway. And this is true, but I used some copyrighted images in the first layout, and asked the creator for permission. And I didn’t get permission to use the images. :-/

Maybe the smaller size is due to better compression and then it gets decompressed at runtime which causes the low fps.

That would be my guess.

gui1.gif is 16 colors (4bpp),
gui2.gif is 256colors (8bpp).

Obviously Java2D fails to accelerate 4bpp images.

tbh I would rate that in itself as a bug.

What version JRE are you using?

C:\Documents and Settings\knot>java -version
java version “1.5.0_01”
Java™ 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot™ Client VM (build 1.5.0_01-b08, mixed mode, sharing)

The workaround (which isn’t realy a workaround at all, more like the correct way of doing it) is to load in the image through ImageIO, and then copy it into a BufferedImage obtained from createCompatibleImage.

You are then guaranteed it will be accelerated (if possible).

There are numerous threads covering this, and even a wiki entry with code example.

A quick google found it :-

http://wiki.java.net/bin/view/Games/LoadingSpritesWithImageIO