Accelerated BufferedImage from Byte[]

Hello,

I’m getting an RGB24 image from JNI as a Byte Array and need to get a Buffered Image of it.
Currently I’m using this code:

final DataBufferByte db = new DataBufferByte(new byte[][] {bytes}, bytes.length);
	final ComponentSampleModel sm = new ComponentSampleModel(DataBuffer.TYPE_BYTE, w, h, 3, w * 3, new int[] {2, 1, 0});
	final WritableRaster r = Raster.createWritableRaster(sm, db, new Point(0, 0));
            final ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
            int[] nBits = {8, 8, 8};
            final ColorModel colorModel = new ComponentColorModel(cs, nBits, false, false,
                                                 Transparency.OPAQUE,
                                                 DataBuffer.TYPE_BYTE);
            final BufferedImage bi = new BufferedImage(colorModel, r, false, null);

It is pretty fast, but the returned bufferedImage ist not accelerated (isaccelerated() return false), so I tried to copy it into a compatibleImage for scaling it (or it will be verrry slow). The CompatibleImage is faster, but it still returns false on isaccelerated().
Is there a faster way to directly get an accelerated BufferedImage from the Byte Array??
Because copying an 1600x1200 Image to a CompatibleImage everytime is taking too much time.

You could create a VolatileImage and copy to it. That way you’ll have one sysmem->vram upload, and then subsequent copies will be accelerated.

However, if your byte array image changes on every frame this approach won’t really help that much unless you’re doing scaling/transforms.

An alternate and unsupported approach is described here:
http://www.mail-archive.com/java2d-interest@capra.eng.sun.com/msg04391.html

Dmitri