Hi,
in JDK 1.1 days, one always uses MemoryImageSource to form animation from an
image pixel data buffer. For example,
int pixels[];
MemoryImageSource source;
public void init() {
int width = 50;
int height = 50;
int size = width * height;
pixels = new int[size];
int value = getBackground().getRGB();
for (int i = 0; i < size; i++) {
pixels[i] = value;
}
source = new MemoryImageSource(width, height, pixels, 0, width);
source.setAnimated(true);
image = createImage(source);
}
public void run() {
Thread me = Thread.currentThread( );
me.setPriority(Thread.MIN_PRIORITY);
while (true) {
try {
thread.sleep(10);
} catch( InterruptedException e ) {
return;
}
// Modify the values in the pixels array at (x, y, w, h)
// Send the new data to the interested ImageConsumers
source.newPixels(x, y, w, h);
}
}
But use MemoryImageSource suffers performance problem. For example, if the
pixel data array is large, then the animation fps is slow, or if want to do an
fullscreen animation, MemoryImageSource is weak.
In JDK 1.5, there are BufferedImage, VolatileImage and BufferStrategy which
can be hardware accelerated. However, if operate on the pixel data buffer
directly, Java 2D engine can't use hardware acceleration.
So, my question is : Is there a method can produce pixel based animation and
use hardware acceleration instead of MemoryImageSource?
[Message sent by forum member 'ylzhao' (ylzhao)]
http://forums.java.net/jive/thread.jspa?messageID=129139
===========================================================================
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".