Help figuring out JCD's ImageLoader class

In JCD’s WaterCubeMap demo he loads the images using a class called ImageLoader to create BufferedImage objects, however, he converts the actual data of the images manually before passing the created ImageComponent2D object–why? I tried just passing back just the bufferedImage–unaltered–but it came out looking dark bluish.

Looking through some other examples of his, I noticed that he has two different versions of the ImageLoader class, one that does the conversion, and one that doesn’t.

The one that doesn’t do the conversion is his TextureCubeMap example. I’m beginning to suspect this has to do with image formats… and it is true that the two programs use different formats: WaterCubeMap uses JPGs, and TextureCubeMap uses PNGs.

Is this the reason that the byte-wise manipulation was neccessary (because they’re JPG files)? If it is, why is it neccessary? Or is the actual reason he’s converting them completely different?

Any help helping me understand this would be greatly appreciated.

That freakin JCD, sup with him not throwing any comments in his code >:(
You were right about your guess regarding the image format; JPGs are packed in BGRs whereas PNGs could be RGBs, ARGBs or Luminance.
Therefore, drawing the images to a Java panel or BufferedImage will always result into either an RGB or ARGB that I can use to properly create compatible textures with OPENGL.
:slight_smile:

Hmmm… I think I understand what you’re saying, but forgive me, I lack detailed knowledge of the differences between formats and how manipulating them can change one into the other.

Do I understand you correctly: You’re changing all images, JPG or PNG, into another format, and conveniently by doing the same operation on both you can still get a working format??

So does this mean that Xith3D has problems with JPG’s and that if I want to use them I should use this converstion method? Is the general rule of thumb then to just use PNGs for textures and therefore bypass this conversion?

Do you know of any sites that I can read to help me better understand all this image manipulation stuff?

A good start :slight_smile:
http://www.flipcode.com/tutorials/tut_atmap.shtml

thanks, nice site.