开发者

removing drawn image from java me canvas

is it pos开发者_运维百科sible to remove a drawn image from the canvas ? after it have been called in paint(Graphics g) with a certain condition


I cannot speak for Java ME directly, but if the paint and Graphics methods work in a similar way to standard Java -- and it sounds as though they do -- then you can't unpaint an image.

In standard Java you can create a BufferedImage (see java.awt.image). You draw on the buffered image, and then draw that onto the canvas. That way you can have more than one buffer frame if need be.

You can use a second buffer to copy out the area underneath the picture you are rendering. Then to 'unpaint' it, you could just copy that content back.

If this is for a game, it is probably best to render each frame to the next available back-buffer (keep one or two). Again, I am not certain of J2ME specific restrictions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜