i have some native code, which produces a bytebuffer with a raw 24 bit image.
what steps should i take to display this image?
Create a BufferedImage and manually set each pixel.
BufferedImage img = new BufferedImage(800, 600, BufferedImage.TYPE_3BYTE_BGR);
img.getRaster().setDataElements(0, 0, 800, 600, imageData);
I don’t think you can pass a ByteBuffer along as an argument there (someone correct me?)
What I would do is use array() to get the backing buffer and work from there
deepthought said he got the ByteBuffer from native code, so it’s a direct ByteBuffer. .array() won’t work there.
You have to copy the contents of the ByteBuffer into an array manually, using byteBuffer.get(byte[])
The argument is of type Object. The JavaDocs say that it should be an array of the type returned by Raster.getTransferType().
that works. and there i was arsing around with MemoryImageSources
What type is your imageData?
3 byte RGB. the native code could just be rewritten to use BGR.
just wondering, is there any way to make a 3 byte RGB colormodel?
I meant what type of array?
byte