J2ME Image / Graphics my misunderstanding?
Hi,
I have a mutable Image which I am using as an offscreen buffer. I initialise this image by setting the colour to white and calling the fillRect() method with the screen size as parameters. I do this in the constructor for my Canvas object.
In my paint() method I then draw only the extra things on the backbuffer (since I have already filled the image with white) and use the drawImage() method of the screens Graphics object to copy the backBuffer onto the screen of my device.
The problem is that text from the previous Form shows up, as if I have not filled the backBuffer with a white rectangle....
Code :
Initialisation :
backBuffer = Image.createImage(screenWidth,screenHeight);
Graphics g = backBuffer.getGraphics();
g.setColor( 255, 255, 255 );
g.fillRect( 0, 0, getWidth(), getHeight() );
In my paint() method :
Graphics saved = g; // Save the frame buffer
g = backBuffer.getGraphics();
g.setColor(255,0,0); // change the colour to red
// Draw the selection box.
g.drawRect(x,y,imageWidth,imageHeight);
saved.drawImage(backBuffer,0,0,Graphics.LEFT|Graphics.TOP);
Thanks,
Norris

