Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
Native memory backed BufferedImage with NIO
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Roland Richter, post: 587739"] Dear all, I work on an application which grabs/creates images in a native DLL (written in C++, using Intel's IPP) and displays them in a Java Swing GUI, using a class which displays a given BufferedImage. This, of course, involves some conversions: 1) On the Java side: Call ((DataBufferByte)bufferedImage.getRaster().getDataBuffer()).getData() to obtain a "pointer" to the byte array which backs the BufferedImage. 2) Pass that pointer to the JNI side and copy the contents of the native image into that arry, something like env->SetByteArrayRegion( (jbyteArray)target, 0, size, native_data ); I wonder whether copying in step 2) could be avoided. java.nio is said to provide direct byte buffers for exactly this purpose. However, I could not figure out the details, so I need some help. Seems like there are two possibilites: 1) On the JNI side, create a ByteBuffer with NewDirectByteBuffer(); hopefully, this buffer is backed by an array (??!), so that one can call the array() method on the Java side and use this byte[] to create a BufferedImage. 2) Create a memory mapped file / MappedByteBuffer on the Java side; get its address calling GetDirectBufferAddress() on the JNI side, and use this memory area for the native images. Both approaches seem error-prone to me; sure I'm missing something??? Any help is highly appreciated. - Roland [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
Native memory backed BufferedImage with NIO
Top