well, just in case you don't know, there are 3 different types of transparencies in Java:
- Opaque - all pixels are visible (no transparent pixels)
- Bitmask - all pixels are either 100% visible or 100% transparent (no middle-ground here)
- Translucent - pixels can be partially visible and partially transparent
Now there's a difference between GIF and PNG. GIFs can only save in the opaque or bitmask mode. It doesn't support translucent pixels. PNG, however, supports all 3 transparencies. The problem with your FPS is hardware acceleration.
Hardware acceleration makes use of your video card and speeds up Image processing. One way to create an accelerated Image is to use this method from the GraphicsConfiguration
That last parameter is an int provided by the Transparency
class. You can use either Transparency.OPAQUE, Transparency.BITMASK, or Transparency.TRANSLUCENT
The problem is Java only supports acceleration for BITMASK and OPAQUE - which is why your PNG with translucent pixels chokes the FPS. Not to mention it takes alot of computing power anyway to composite translucent pixels.
There are a few things you can try to get around your problem:
- Don't use transparency for your mountains. If the background image doesn't change in some way, there's no reason for the transparency in the mountains. Save the mountains with the same color background that the real background uses
- Enable the OpenGL pipeline (Java 1.5 only) by passing this option in the command-line: -Dsun.java2d.opengl=true
- Use an OpenGL library (LWJGL, Xith3D, jME, etc.) - These libraries give you access to OpenGL's capabilities. The OpenGL is all hardware accelerated and OpenGL can handle translucency much more decently than average Java