The VideoOverlayMIDlet
class is the MIDlet main
class. It controls the other classes and displays the different views.
The following code creates the required canvases: two for displaying video and one for displaying the image taken in the camera view.
public void startApp() { // Creating canvases displayCanvas = new DisplayCanvas(this); cameraCanvas = new VideoCanvas(this, CAMERA); videoCanvas = new VideoCanvas(this, VIDEO); // Creating list to select VideoControl type mainmenuList = new List("VideoOverlayMIDlet", Choice.IMPLICIT); fillList(); mainmenuList.addCommand(openCommand); mainmenuList.addCommand(exitCommand); mainmenuList.setCommandListener(this); Display.getDisplay(this).setCurrent(mainmenuList); }
The following method is used to start the image view. It takes
the image to display as an argument and sets the DisplayCanvas
to full screen.
void cameraCanvasCaptured(byte pngData[]) { cameraCanvas.stop(); Display.getDisplay(this).setCurrent(displayCanvas); displayCanvas.setFullScreenMode(cameraCanvas.isFullScreen()); displayCanvas.setMode(cameraCanvas.isFullScreen()); displayCanvas.setImage(pngData); }
The video and camera view are started with the following method:
void videoCanvasStart(int videotype, int buttontype) { if (videotype == CAMERA) { Display.getDisplay(this).setCurrent(cameraCanvas); cameraCanvas.startCanvas(buttontype); } else { Display.getDisplay(this).setCurrent(videoCanvas); videoCanvas.startCanvas(buttontype); } }