TM.loadImage(Image) doesn't properly load/convert some imgs

TextureManager.loadImage(java.awt.Image, …) doesn’t properly load/convert some images



I’ve noticed with some image files that the loadImage routine doesn’t properly convert them. They show off-by-some row alignment problems (as if the row width was too long by a little bit).



Taking the same java.awt.image and feeding into ImagedBasedHeightMap doesn’t produce the distortion, so I think it’s only a problem with the com.jme.image.Images (although it could be an LWJGL problem).



Resizing the image to an "odd size’ will reproduce the problem.

Ie, 256x256 is fine. 511x511, 257x257, or 895 x 1296 doesn’t work well. I won’t say for sure what constitutes a “bad” width, but it’s probably a non-multiple of 8.





a b c d e f g
.a b c d e f g
g a b c d e f
.g a b c d e f



instead of


a b c d e f g
a b c d e f g
a b c d e f g
a b c d e f g



Windows 2000, today's jME, jdk 1.4.2, TNT2 Model 64 Pro

As the guest said, only the most recent cards using the latest extensions support non-power of two textures. So, IF you are trying to view your image via texture mapping, you are going to get strange results with non-power of two images.

Actually, I’m seeing this in WidgetLWJGLImage with glDrawPixels. I used loadTexture() to create a jme.image.Image since it seems a good way to convert a java.awt.Image into an NIO ByteBuffer image representation.



As far as I could tell, there’s nothing specific to jme.image.Image or TextureManager.loadImage() that depends on powers of two, but I figured I should run it by you in case I overlooked anything.



Well, this turned out to be helpful. I went back and read the fine print for glDrawPixels, and I see that i need to specify



GL11.glPixelStorei (GL11.GL_UNPACK_ALIGNMENT, 1);



or it will default to four bytes per pixel.