11 messages in net.java.dev.jna.usersRe: [jna-users] Re: shaped windows us...
FromSent OnAttachments
Timothy WallMay 24, 2007 7:12 am 
Christopher DeckersMay 29, 2007 2:21 am 
Christopher DeckersMay 29, 2007 3:29 am 
Wayne MeissnerMay 29, 2007 3:53 am 
Christopher DeckersMay 29, 2007 7:10 am 
Wayne MeissnerMay 29, 2007 7:43 am 
Timothy WallMay 29, 2007 11:04 am 
Olivier ChafikMay 29, 2007 6:19 pm 
Christopher DeckersMay 29, 2007 11:56 pm 
Timothy WallMay 30, 2007 5:19 am 
Christopher DeckersMay 30, 2007 6:10 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] Re: shaped windows using images - performanceActions...
From:Wayne Meissner (wmei@gmail.com)
Date:May 29, 2007 7:43:26 am
List:net.java.dev.jna.users

Christopher Deckers wrote:

One thing you might want to do is to get the backing array for each of the images. I've found reading/writing pixels directly to be a lot faster than the getRGB()/setRGB() calls.

e.g. int[] pixels = ((DataBufferInt) newImage.getRaster().getDataBuffer()).getData();

I have to admit I am a bit lost in all those Image-related APIs. Image handling (rasters, color models, etc.) is an area where I need to learn a bit more. Any pointers to resources to learn about all these internal details?

Good places for info are the java2d forums on java.net and the javagaming.org 2D forums.

In the call you describe, I guess I can modify the ARGB values directly in the array of pixels, but how do I apply my new array?

That array (for a TYPE_INT_ARGB or TYPE_INT_RGB BufferedImage) is the actual array of pixels the BufferedImage uses as its backing store, so changing the values in the array is the same as the setRGB() call - but much faster.

The only caveat is that getting the Raster for the BufferedImage unmanages it - i.e. it can't be accelerated (put into VRAM) anymore, so if you draw from it a lot (e.g. uses it as the first param in a Graphics.drawImage() call), then you might want to draw it into a new BufferedImage or VolatileImage once you have done bit twiddling it. Usually you don't need to worry about that though.