public void run() {
      try {
        //				byte [] snap = videoControl.getSnapshot("encoding=jpeg&width=160&height=120");
        byte[] snap = videoControl.getSnapshot("encoding=jpeg");
        if (snap != null) {
          Image im = Image.createImage(snap, 0, snap.length);
          int a = im.getHeight();
          int b = im.getWidth();

          System.out.println("my height is " + a);
          System.out.println("My width is " + b);
          Alert al = new Alert("MyImage", "My dimensions are:" + b + "," + a, im, AlertType.INFO);
          al.setTimeout(2000);
          parentMidlet.getDisplay().setCurrent(al, aVideoCanvas);
        }
      } catch (MediaException me) {
        System.err.println(me);
      }
    }
예제 #2
0
  public void capture() {
    try {
      // Get the image.
      byte[] raw = mVideoControl.getSnapshot(null);
      Image image = Image.createImage(raw, 0, raw.length);

      Image thumb = ImageUtility.createThumbnail(image);

      // Place it in the main form.
      if (mMainForm.size() > 0 && mMainForm.get(0) instanceof StringItem) mMainForm.delete(0);
      mMainForm.append(thumb);

      // Flip back to the main form.
      mDisplay.setCurrent(mMainForm);

      // Shut down the player.
      mPlayer.close();
      mPlayer = null;
      mVideoControl = null;
    } catch (MediaException me) {
      handleException(me);
    }
  }