hi
I have written a BufferedImage extension, that uses a special DataBuffer implementation, that stores its data directly in a DirectByteBuffer. I need this to avoid data duplication in memory. The image data needs to be sent to OpenGL, which can only be done through the ByteBuffer. To keep the image updatable/redrawable, I need the linkage between the BufferedImage and the ByteBuffer. Therefore I need this solution.
I currently have a working solution, but it is incredibly slow. This led me to this nice section of these boards ;).
I have implemented it by creating a WritableRaster extension, that takes a PixelInterleavedSampleModel (instantiated just as BufferedImage does) and my DirectDataBufferByte. The documentation says, that the ByteInterleavedRaster is being used by a BufferedImage for byte-data to improve performance. I would like to use it, too, but it doesn’t accept my DirectDataBufferByte (the one, that is backed by a ByteBuffer). Unfortunately the source of ByteInterleavedRaster and its parent classes doesn’t seem to be available, so I cannot loopup, what they do to improve performance.
The only difference between my DirectBufferedImage and the regular BufferedImage (with bytes) is the used WritableRaster. But the original BufferedImage is 3x as fast as my DirectBufferedImage. And writing the data to a byte array or a ByteBuffer doesn’t make any difference in performance. So, I guess, I only need a better WritableRaster implementation.
I hope, I was clear enough and someone can help me out here. If there are any further questions, please don’t hesitate to ask.
Thanks in advance,
Marvin