简体   繁体   English

RecordStore 和手机拍摄的照片

[英]RecordStore and photos taken from the phone

When the user takes photos with his phone I want LWUIT to get a specific photo to add to a recordstore and later retrieve that photo.当用户用他的手机拍照时,我希望 LWUIT 获取一张特定的照片以添加到记录存储中,然后再检索该照片。 How to achieve that?如何做到这一点?

RMS is not good for storing the Photo's. RMS不适合存储照片。 Because RMS designed for small amount of storage.因为 RMS 专为少量存储而设计。 You can't handle huge amount of data.您无法处理大量数据。 Better you can read from phone memory or memory card.更好的是您可以从手机 memory 或 memory 卡中读取。 Also how you can take the currently captured photo without your application?另外,如何在没有应用程序的情况下拍摄当前拍摄的照片?

Edit:编辑:

You can develop the application for taking the photo and store it in RMS(But not huge amount) or store it in server through calling web service .您可以开发用于拍照的应用程序并将其存储在 RMS 中(但不是大量)或通过调用web 服务将其存储在服务器中。

Ok, I make the application starts the camera through a command:好的,我让应用程序通过命令启动相机:

mPlayer = Manager.createPlayer("capture://video");
mPlayer.realize();

mVideoControl = (VideoControl) mPlayer.getControl("VideoControl");

Canvas canvas = new CameraCanvas(this, mVideoControl);
canvas.addCommand(mBackCommand);
canvas.addCommand(mCaptureCommand);
canvas.setCommandListener(this);
mDisplay.setCurrent(canvas);
mPlayer.start();

In the actionPerformed of the mCaptureCommand command:在 mCaptureCommand 命令的 actionPerformed 中:

public void capture() {
        try {
            // Get the image.
            byte[] raw = mVideoControl.getSnapshot(null);
//                    "encoding=png&width=320&height=240");
            bytelen = raw.length;
            Image image = Image.createImage(raw, 0, raw.length);

            Image thumb = 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);
        }
    }

The code of createThumbnail: createThumbnail 的代码:

private Image createThumbnail(Image image) {
        int sourceWidth = image.getWidth();
        int sourceHeight = image.getHeight();

        int thumbWidth = 64;
        int thumbHeight = -1;

        if (thumbHeight == -1) {
            thumbHeight = thumbWidth * sourceHeight / sourceWidth;
        }

        Image thumb = Image.createImage(thumbWidth, thumbHeight);
        Graphics g = thumb.getGraphics();

        for (int y = 0; y < thumbHeight; y++) {
            for (int x = 0; x < thumbWidth; x++) {
                g.setClip(x, y, 1, 1);
                int dx = x * sourceWidth / thumbWidth;
                int dy = y * sourceHeight / thumbHeight;
                g.drawImage(image, x - dx, y - dy, Graphics.LEFT | Graphics.TOP);
            }
        }
        Image immutableThumb = Image.createImage(thumb);
        return immutableThumb;
    }

Now I do not know where the Image is stored when calling the createThumbnail method, that is after calling Image.createImage: there are two createImage calls one in the capture() method and one in the createThumbnail() method.现在调用createThumbnail方法时不知道Image存储在哪里,也就是调用Image.createImage之后:有两个createImage调用,一个在capture()方法中,一个在createThumbnail()方法中。 But my real problem is to know the location of the created image and how to associate it with a banking-client recordStore id.但我真正的问题是要知道创建的图像的位置以及如何将它与银行客户的记录存储 ID 相关联。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM