Hello,

  I think you can do something like this:

  1. Create a BufferedImage of appropriate type (say, INT_RGB)
  2. get the array from the DataBuffer
     (((DataBufferInt)(BI.getRaster().getDataBuffer())).getData() in case
     of INT_[A]RGB image type) and pass it to the native code
  3. At the native level, use GetPrimitiveArrayCritical to get the
     pointer to the data, copy your image data
  4. Render your BufferedImage at the java level

  This is more or less what Swing does when rendering the native Look
  and Feels.

  Note that in this case the resulting BufferedImage will not be
  HW-accelerated - that is, cached in vram. You can do it by yourself
  by creating  a VolatileImage and copying the BI to the VI, and then VI
  to the screen - this makes sense only if you don't update the BI
  on every frame and the cached VI can give you an advantage, though.

  Thanks,
    Dmitri


On Wed, May 10, 2006 at 02:52:38PM -0700, [EMAIL PROTECTED] wrote:
 > I have a need to get image data from native code to a Java Image, e.g. a 
 > BufferedImage, in the most efficient manner possible.
 >
 > Ideally I would like to write to the BufferedImage's raster directly in my 
 > native code, or get an image from a DirectByteBuffer of RGB pixel data.  If 
 > I can reuse the same Image object multiple times to avoid excessive garbage 
 > creation that would be best.
 >
 > I'm looking for options and pointers on how I should implement such a thing 
 > while avoiding as much as possible any data copying.  It is likely that my 
 > data will need to be converted from YUV color space to RGB color space and I 
 > would like for that to be the only time the data is copied.  So I would 
 > convert directly into the BufferedImage with my native color conversion (and 
 > in some cases scaler) loop which is already optimized with SIMD assembler.
 >
 > Thanks in advance.
 > [Message sent by forum member 'swpalmer' (swpalmer)]
 >
 > http://forums.java.net/jive/thread.jspa?messageID=112638
 >
 > ===========================================================================
 > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
 > of the message "signoff JAVA2D-INTEREST".  For general help, send email to
 > [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to