The DisplayCanvas
class displays the picture captured
in the camera view.
The key method in this class is the paint
method, which draws the canvas with
the image:
public void paint(Graphics g) { g.setColor(BACKGROUND_COLOR); g.fillRect(0, 0, getWidth(), getHeight()); if(image != null) g.drawImage(image, getWidth()/2, getHeight()/2, Graphics.VCENTER | Graphics.HCENTER); // In fullscreen mode, drawing exit button if(fsMode) { // Landscape exitX = image.getWidth(); exitY = image.getHeight() - (back_icon.getHeight()+20); g.drawImage(back_icon, (exitX+getWidth())/2, exitY, Graphics.TOP | Graphics.LEFT); } }
The setImage
method is used to turn an array
of bytes in to an Image
object:
void setImage(byte pngImage[]) { image = Image.createImage(pngImage, 0, pngImage.length); }