I have a C++ library that does image processing on rectangular arrays of pixels. I want to pass the output C++ pixels to java so they can most effciently be "drawn" into a java.awt.Graphics2 instance for a canvas as an Image/Raster/(?) object( yeah not the best way but it is a legacy app )

I am looking for the best way to do this for performance, as the image can be "animated" and updates need to be reasonable.

1

There are 1 best solutions below

2
Botje On

The backing store for a Raster object is a DataBuffer, which is an interface you can implement yourself. If you use a DirectByteBuffer you can effectively share a memory region between Java and the native world.