J2ME如何拍照并将其保存到内存中?

时间:2011-02-08 20:13:29

标签: java java-me

拍照并保存。我不需要任何“显示相机视频”等等。因为当代码太多时我无法理解。

1 个答案:

答案 0 :(得分:2)

private void startPlayer() {
   try {
         Player player = Manager.createPlayer("capture://video");
         player.realize();
         videoControl = (VideoControl)
         player.getControl("VideoControl");
         if (m_objVideoControl != null) 
         {
           form.append((Item) videoControl.initDisplayMode(
           VideoControl.USE_GUI_PRIMITIVE, null));
           player.start();
         }
       } catch (Exception ex) {
            // handle it
}

// Use this to take a snapshot
public void commandAction(Command cmd, Displayable d) {
   if ((cmd == snapShotCommand) && d == this) {
    try {
         data =
           videoControl.getSnapshot("encoding=jpeg&width =160&height=120"));
          // videoControl.getSnapshot("encoding=png&width= 80&height=60"));
          // videoControl.getSnapshot("encoding=bmp&width= 160&height=120"));
   } catch (Exception ex) {
     // handle it
   }
}

要将图像存储到DB中,您可以使用RMS。 here它解释了如何

相关问题