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:
1 2 3 4 5 6 7 8 9
| 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.