Im writing a j2me application for mobile...im trying to open the mobile camera in the application and capture the image..how to do it?please reply as soon as possible.
+1
A:
If the MMAPI is supported by the phone, you could take snapshots like this.
//Use this method to initialize
// m_Form is the displayed Form
private void startPlayer() {
try {
Player m_objPlayer = Manager.createPlayer("capture://video");
m_objPlayer.realize();
m_objVideoControl = (VideoControl)
m_objPlayer.getControl("VideoControl");
if (m_objVideoControl != null)
{
m_Form.append((Item) m_objVideoControl.initDisplayMode(
VideoControl.USE_GUI_PRIMITIVE, null));
m_objPlayer.start();
}
} catch (Exception exc) {
// handle Exception
}
// Use this to take a snapshot
public void commandAction(Command cmd, Displayable d) {
if ((cmd == snapShotCommand) && d == this) {
try {
data =
m_objVideoControl.getSnapshot("encoding=jpeg&width =160&height=120"));
// m_objVideoControl.getSnapshot("encoding=png&width= 80&height=60"));
// m_objVideoControl.getSnapshot("encoding=bmp&width= 160&height=120"));
} catch (Exception exc) {
// handle Exception
}
}
Here is an old article on sun click me!
Qwark
2009-01-17 11:31:12