transparency problem since java 1.6.0_20

Hello,
I am loading some transparent pngs:

BufferedImage image = ImageIO.read(url);

then I want to draw them on the gl canvas surface:



width = image.getWidth();
height = image.getHeight();
					
gl.glWindowPos2i(win_x + 5, (win_y - height - 5));
					
byte[] imgRGBA = ((DataBufferByte)interfaceElements.get(i).image.getRaster().getDataBuffer()).getData();
ByteBuffer buffer = ByteBuffer.wrap(imgRGBA);
					
gl.glDrawPixels(width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer);
					

This was working fine until I installed the new java version 1.6.0_20, earlier I was using 1.6.0_14, which was workign nicely!
Now Instead of transparency I got these blueish looking colors.
I read somewhere here, that it has something to do with indexed colors?

Does somebody know how to fix these problem? I was searching for it here, there was an solution from NexusOne, which was not working for me.

kind regards

Knut

What makes you so sure you get the bytes in RGBA format?

Sadly, that is an implementation detail.

Copy the image to a BufferedImage of type RGBA, then access the pixels.

I have done it like this:


                 int width = image.getWidth();
                 int height = image.getHeight();
                
                 BufferedImage newImage = new BufferedImage(width,
                       height, BufferedImage.TYPE_4BYTE_ABGR);
              
                 for(int i = 0; i < width; i++){
                       for(int j = 0; j < height; j++){
                            int k = image.getRGB(i, j);
                            newImage.setRGB(i, j, k);
                       }
                 }      
                
           }

then used the newImage, but there was no difference. What do you exactly mean with accessing the pixels ?

So… you put the pixels in a TYPE_4BYTE_ABGR format… and then tell OpenGL it is RGBA?

I do this with the new BufferedImage.TYPE_4BYTE_ABGR

// get a byte array	
imgRGBA = ((DataBufferByte)interfaceElements.get(i).image.getRaster().getDataBuffer()).getData();

//create bytebuffer				
buffer = ByteBuffer.wrap(imgRGBA);

// draw pixel				
gl.glDrawPixels(width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer);

Do I have to set up different parameters? Is there something wrong with the commands I used?

Let me make this very simple:

You feed the GPU ABGR, and tell it it is RGBA.

Why do you think the color-channels are swapped?

Besides that, please use textures. glDrawPixels() is very limited and very slow.

Ah now the penny has swapped… aeh dropped! Thank you.
Currently I am fine with draw pixels. Maybe I change it later.

Ok thank you.

Also note that using image.getRGB()/image.setRGB() is very slow compared to image.getGraphics().drawImage().