I googled around a bit and nobody seems to have asked this question.
I have images in multiple color formats (all of them are PNGs). Most of them are ARGB but my bitmap fonts are gray scale, and I would like them to stay that way. All I want to do is find out what format
BufferedImage uses to store my pixel data and then use that information with
glTexImage2D. Java, in all its wisdom, seems to be determined to hide that information from me at all costs...
I also need to know how
BufferedImage aligns its pixel data in both of these formats (
Could someone please tell me how to:
- Determine the pixel format of my
BufferedImage. If it is ARGB32, I'm going to have to reorder the bytes and use
GL_RGBA. If it's grayscale, I will be using
- Extract the actual bytes from the image. I have seen a few examples on the web that use
BufferedImage.getRaster().getDataBuffer(). This is nonsensical. Why are there different types of buffers like
DataBufferInt? Because of Java's strong typing, I need
DataBufferByte. If this is the only way, could somebody give me specific directions to use the different type of buffers with
- Figure out how the aforementioned image data is aligned. I will use this information with
In addition, I come from C and C++ programming. In C this was 100 lines of simple libPNG and GL calls. Should I expect more trouble like this in the future?