SomeTexture extends AbstractState { public static ByteBuffer convertToGl_TYPE_TYPE_INT_ARGB(BufferedImage image) { int[] imBuffer = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); ByteBuffer result = BufferUtils.createByteBuffer(imBuffer.length * 4); for (int i = 0; i < imBuffer.length; i++) { int cur = imBuffer[i]; byte inputA = (byte) (((cur >>> 24) & 0xFF)); byte inputR = (byte) (((cur >>> 16) & 0xFF)); byte inputG = (byte) (((cur >>> 8) & 0xFF)); byte inputB = (byte) (cur & 0xFF); result.put(inputR); result.put(inputG); result.put(inputB); result.put(inputA); } result.rewind(); return result; } SomeTexture();  SomeTexture(BufferedImage image);  SomeTexture(int w, int h);  SomeTexture(int[] data, int w, int h); SomeTexture init(int w, int h); void setImage(BufferedImage image); void uploadData(int w, int h, ByteBuffer byteBuffer); static ByteBuffer convertToGL(final BufferedImage image); static ByteBuffer convertToGl_TYPE_3BYTE_BGR(BufferedImage image); static ByteBuffer convertToGl_TYPE_TYPE_INT_ARGB(BufferedImage image); static ByteBuffer convertToGL(int[] ii); static ByteBuffer convertToGLUnoptimized(final BufferedImage image); @Override void enable(); @Override void disable(); @Override void release(); void setSlot(int slot); void enable(int slot); public boolean enabled; public int textureGlSlot; public int textureSlot; public int textureObjectId; public int wrapR; public int wrapS; public int wrapT; public int magFilter; public int minFilter; public int width; public int height; public int internalformat; public int pixelDataFormat; public int pixelDataType; }
@Test public void convertToGl_TYPE_TYPE_INT_ARGB() { BufferedImage bi = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB); Graphics g = bi.getGraphics(); g.setColor(new Color(0, 0, 0, 255)); g.drawLine(0, 0, 10, 0); g.setColor(new Color(255, 0, 0, 255)); g.drawLine(1, 0, 10, 0); g.setColor(new Color(0, 255, 0, 255)); g.drawLine(2, 0, 10, 0); g.setColor(new Color(0, 0, 255, 255)); g.drawLine(3, 0, 10, 0); int[] imBuffer = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData(); System.out.println("Java internal (0xAARRGGBB):"); System.out.println(Integer.toHexString(imBuffer[0])); System.out.println(Integer.toHexString(imBuffer[1])); System.out.println(Integer.toHexString(imBuffer[2])); System.out.println(Integer.toHexString(imBuffer[3])); ByteBuffer buffer = SomeTexture.convertToGl_TYPE_TYPE_INT_ARGB(bi); System.out.println("\nOGL internal (0xAABBGGRR):"); System.out.println(Integer.toHexString(buffer.getInt())); System.out.println(Integer.toHexString(buffer.getInt())); System.out.println(Integer.toHexString(buffer.getInt())); System.out.println(Integer.toHexString(buffer.getInt())); buffer.rewind(); assertEquals(0xFF000000, buffer.getInt()); assertEquals(0xFF0000FF, buffer.getInt()); assertEquals(0xFF00FF00, buffer.getInt()); assertEquals(0xFFFF0000, buffer.getInt()); }