PNG files on HUD

Hey Folks!

Currently having some problems getting a HUD together for a SimpleGame. I'm attempting to put a PNG graphic on the HUD to represent the background.

I'm using the following code (as per the HUD tutorial):

package gameComponents.hud.components;

import java.nio.FloatBuffer;

import com.jme.image.Texture;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.AlphaState;
import com.jme.scene.state.LightState;
import com.jme.scene.state.TextureState;
import com.jme.system.DisplaySystem;
import com.jme.util.TextureManager;
import com.jme.util.geom.BufferUtils;

public class EnemyBackground extends Quad {

   private int textureWidth;

   private int textureHeight;

   // --- Statics
   private static final long serialVersionUID = 2118927990559627147L;

   public EnemyBackground() {
      super("hud", 120f, 120f);

      URL backgroundURL = null;

      try {

         backgroundURL = new File("data/images/grassb.png").toURL();
      } catch (Exception e) {


      Quad hudQuad = this;

      TextureState ts = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
      ts.setTexture(TextureManager.loadTexture(backgroundURL, Texture.MM_LINEAR, Texture.FM_LINEAR, 1.0f, true));
      textureWidth = ts.getTexture().getImage().getWidth();
      textureHeight = ts.getTexture().getImage().getHeight();

      FloatBuffer texCoords = BufferUtils.createVector2Buffer(4);
      hudQuad.setTextureBuffer(0, texCoords);

      AlphaState as = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();



   private float getUForPixel(int xPixel) {
      return (float) xPixel / textureWidth;

   private float getVForPixel(int yPixel) {
      return 1f - (float) yPixel / textureHeight;


If I attempt to use the PNG file downloaded from the Tutorial, it works fine! However if i substitute this file with any other that I make using Fireworks of Photoshop, they do not show up correctly. Instead a random set of pixels seem to appear.

Any help or guidance would be greatly appreciated!

If it has any significance I'm a Mac user!

photoshop has several options when you save a png file, make sure its not interlaced and check for other settings

theprism said:

photoshop has several options when you save a png file, make sure its not interlaced and check for other settings

Checked the interlaced property, still is not working!!!!

The PNG file I'm using (as-is):

How it appears (3 instances on HUD):

Any other ideas?

If you use the same png but saved from Paint, he works?

Don't know, i don't have paint

the image shown looks suprisingly like the missing texture image, confirm it loads the image - put it in same directory as grassb

I have put it in the same directory as grassb, and still no joy. However, grassb itself works fine!

It just appears to be PNG graphics I am creating locally…?

Got it!!! The PNG file I was using did not have dimensions that are powers of 2!!! I can't believe it was something as stupid as that d'oh!!!

Cheers guys!!