I need to create Bitmaps in C++ with the ndk and pass them to Java. I don’t mean copy but actually pass them as a parameter or return value or anything else like that because copying them would be far too slow. I also really need to create them in the NDK part and not in java.
Does anyone know a way to do that ?
As Peter Lawrey already pointed out using a non-Java object is not possible however it may be possible to directly paint the raw data from a simple Java byte array (which can be directly accessed on the C++ side).
In the end you could even call Canvas.drawBitmap(..) using this byte array for painting your created image. Of course that requires to store the image on C++ side directly in the required format inside the byte array.
Java:
Then pass the
byte[]reference to the native C++ implementation. On C++ side you can callC++: