Different result image between by TextureManager and by ImageGraphics

Some png image shows different result when loaded by TextureManager / drawed by ImageGraphics.

Left box is loaded by TextureManager (incorrect) and

Right box is drawn by ImageGraphics (correct).

If you closely look at the image, you can see the difference.

The gradation of left box is not the same as original image.

(Left box is somewhat reddish and image pattern is not the same as original image)

I tried changing texture filtering option, but it doesn’t help at all.

Below is the test code and the image

Any help will be appreciated. thanks in advance.


import java.awt.Image;
import java.net.URL;

import javax.swing.ImageIcon;

import com.jme.app.SimpleGame;
import com.jme.image.Texture;
import com.jme.image.Texture2D;
import com.jme.image.Texture.MagnificationFilter;
import com.jme.image.Texture.MinificationFilter;
import com.jme.renderer.Renderer;
import com.jme.scene.Spatial.LightCombineMode;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.TextureState;
import com.jme.util.TextureManager;
import com.jmex.awt.swingui.ImageGraphics;

public class TestImage extends SimpleGame {

   private static final String IMAGE_PATH = "popup_512x512.png";

   protected void simpleInitGame() {
      Quad q1 = new Quad("q1", 512, 512);
      Quad q2 = new Quad("q2", 512, 512);
      q1.setLocalTranslation(256, 256, 0);
      q2.setLocalTranslation(512+256, 256, 0);
      // set texture image loaded by TextureManager
      setTexture(q1, IMAGE_PATH, MinificationFilter.BilinearNearestMipMap, MagnificationFilter.Bilinear);
      // set texture image by drawing AWTImage
      URL url = getClass().getResource(IMAGE_PATH);
      final ImageIcon icon = new ImageIcon(url);
      Image awtImage = icon.getImage();
      ImageGraphics g = ImageGraphics.createInstance(512, 512, 0);
      Texture tex = new Texture2D();
      g.drawImage(awtImage, 0, 0, null);
      TextureState state2 = display.getRenderer().createTextureState();

   private void setTexture(Quad q, String path, MinificationFilter min, MagnificationFilter mag) {
      TextureState state = display.getRenderer().createTextureState();
      Texture tex = TextureManager.loadTexture(path, min, mag, 0, false);

   public static void main(String[] args) {
      TestImage test = new TestImage();

jME uses compression by default for images. You can disable it with TextureManager.ENABLE_COMPRESSION = false (or similar, don't remember exact now right now).

Thank you a lot!

It was the cause!

You are really a treasure house of knowledge. :smiley:

Oh, it's moluva! I thought it was some new guy lol

Just for the rest of us:

TextureManager.COMPRESS_BY_DEFAULT = false;