j2me申请

时间:2009-01-17 11:20:02

标签: image-capture

我正在为移动设备编写一个j2me应用程序...我试图在应用程序中打开移动摄像头并捕获图像..如何操作?请尽快回复。

1 个答案:

答案 0 :(得分:1)

如果手机支持MMAPI,您可以拍摄这样的快照。

//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
   }
}

这是关于太阳click me!

的旧文章