Small change in TextureManager

I rewrote a small part of TextureManager for my own purposes and I think that this way is more logical than the way it currently works.

In jMonkey, when a texture is loaded with ImageIO and is not already in proper (A)BGR-format or if the texture needs to be flipped, it is transferred to the texture by using Graphics2D.drawImage(…). This is a valid technique for all opaque images, but for images with an alpha-channel, the RGB-values of the pixels will turn black with low alpha-values.

I changed the following:

public static com.jme.image.Image loadImage(java.awt.Image image,

Was this based on the latest version from CVS?  Texture support has changed somewhat in the past few days…I haven't had a chance to look at it, but if this isn't based on that you might be wasting your time. :wink:

At the time of this post, the code above matches the CVS-version. I updated from CVS this morning before I wrote the code.

I agree that using drawImage is not a good idea. Good catch :slight_smile:

But getRGB is also not the best if the format is the same. Using setDataElements should be faster. It would probably be even faster than drawImage…

Did you test it performance wise? Is it really slower than draw?

posting a patch instead of that whole code would have increased readability, btw

minor point: array size should be imageWidth not imageWidth*4, shouldn't it?

The reason I used getRGB/setRGB was that it allowed me to use the same routine to convert from any colorspace into ABGR. getDataElements/setDataElements is proabably faster as you say, but it would require manual swizzling or conversion (in the case of indexed colorspaces for instance) of the components. I have not done any benchmarks to test the speed of the implementation with getRGB, but I have not noticed a drop in performance in my testcases.

Yes, sorry, the array size should be imageWidth.

any word from mojo or renanse - should this be committed?

Seemed ok to me when it was first proposed.

Ok, this was hanging around in my local copy for a long time now. Committed to cvs. Thanks marqx.