Player p;
VideoControl vc;
// initialize camera
try {
p = Manager.createPlayer("capture://video");
p.realize();
// Grab the video control and set it to the current display.
vc = (VideoControl)p.getControl("VideoControl");
if (vc != null) {
Form form = new Form("video");
form.append((Item)vc.initDisplayMode(vc.USE_GUI_PRIMITIVE, null));
Display.getDisplay(midlet).setCurrent(form);
}
p.start();
} catch (IOException ioe) {
} catch (MediaException me) { }
// now take a picture
try {
byte[] pngImage = vc.getSnapshot(null);
// do something with the image ...
} catch (MediaException me) { }