I'm haveing a strange problem -- I've used MemoryImageSource before with
great success. But now, doing the same thing I've done before in Java 1.4
I'm getting flickering on newPixels() in Java 1.5...
That is, when I send new pixels to my MemoryImageSource mis and repaint() the
image flickers badly. Didn't do this in 1.4.
The odd thing is that --
while((status = bg.drawImage(canvasImage,0,0,thisW, thisH,this)) == false);
never breaks because bg.drawImage never returns true. Do I have to use a
MediaTracker
or something???
Here's what I'm doing -- I've tried it using BufferStrategy and get the same
flicker
//this is an AWT Canvas
private Image canvasImage = null;
private Image buffer = null;
private Graphics2D bg = null;
private MemoryImageSource mis = null;
private ColorModel cm = null;
init()
{
thisW = this.getWidth();
thisH = this.getHeight();
mis = new MemoryImageSource(thisW,thisH,pixels,0,thisW);
mis.setAnimated(true);
mis.setFullBufferUpdates(true);
canvasImage = this.createImage(mis);
buffer = this.createImage(thisW, thisH);
bg = (Graphics2D)buffer.getGraphics();
}
public void paint(Graphics g)
{
g.drawImage(buffer,0,0,thisW, thisH,this);
}
public void newPixels(int [] newPixels)
{
mis.newPixels(newPixels, ColorModel.getRGBdefault(),0, thisW);
boolean status = false;
//while((status = bg.drawImage(canvasImage,0,0,thisW, thisH,this)) ==
false);
bg.drawImage(canvasImage,0,0,thisW, thisH,this);
this.repaint();
}
===
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".