Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.awt.image.DataBufferByte from java.nio.ByteBuffer

843829Jan 5 2005 — edited Feb 19 2005
I am developing software to display ECW and MrSID-formatted images in Java. The pixels in these image formats can only be accessed by using their respective native libraries. So I created a JNI interface around the ECW and MrSID API's to transfer the image pixels using NIO direct byte buffers. These transfers involve a large number of pixels (about 1 million pixels of 3 bytes each) during each screen refresh (panning and zooming).

On the Java side I display the images using a BufferedImage to draw onto a Graphics2D. Unfortunatly there seems to be no way to create a BufferedImage/Raster from the native byte buffer I use to transfer the pixels. Therefore I have to COPY ALL PIXELS each screen refresh. If I could just get a byte[] array from the direct buffer, I could easily create a Raster and BufferedImage from it. For now I am stuck with copying megabytes of data each screen refresh.

Anybody have any ideas on how I could avoid the copying? Or is there a direct way to create a Raster/java.awt.image.DataBufferByte from a direct java.nio.ByteBuffer?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 19 2005
Added on Jan 5 2005
2 comments
560 views