0

我正在为移动设备编写一个 j2me 应用程序...我试图在应用程序中打开移动相机并捕获图像..怎么做?请尽快回复。

4

1 回答 1

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

这是一篇关于太阳的旧文章点击我!

于 2009-01-17T11:31:12.447 回答