I added a method into my local copy of TextureManager, and I wanted to submit it for possible addition into jme. Basically, it's code extracted from the loadTexture method to return just the com.jme.image.Image that is loaded. I found it very useful for doing image data loading without having to bind it to a GL texture id. Here's the method code:
public static com.jme.image.Image loadImage(URL file, boolean flipped) {
String fileName = file.getFile();
if (fileName == null)
return null;
// TODO: Some types currently require making a java.awt.Image object as
// an intermediate step. Rewrite each type to avoid AWT at all costs.
com.jme.image.Image imageData = null;
try {
String fileExt = fileName.substring(fileName.lastIndexOf('.'));
if (".TGA".equalsIgnoreCase(fileExt)) { // TGA, direct to imageData
imageData = TGALoader.loadImage(file.openStream());
} else if (".DDS".equalsIgnoreCase(fileExt)) { // DDS, direct to
// imageData
imageData = DDSLoader.loadImage(file.openStream());
} else if (".BMP".equalsIgnoreCase(fileExt)) { // BMP, awtImage to
// imageData
java.awt.Image image = loadBMPImage(file.openStream());
imageData = loadImage(image, flipped);
} else { // Anything else
java.awt.Image image = ImageIO.read(file);
imageData = loadImage(image, flipped);
}
} catch (IOException e) {
// e.printStackTrace();
LoggingSystem.getLogger().log(Level.WARNING,
"Could not load: " + file + " (" + e.getClass() + ")");
imageData = null;
}
return imageData;
}
and it's called in
loadTexture(URL file, int minFilter, int magFilter, int imageType, float anisoLevel, boolean flipped)
Like I said, simple method extraction, but I found it very useful.