RecordStore 和手机拍摄的照片

发布于 2024-11-15 12:18:37 字数 60 浏览 4 评论 0原文

当用户用手机拍照时,我希望 LWUIT 获取特定照片以添加到记录存储中,然后检索该照片。如何实现这一目标?

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. How to achieve that ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雨夜星沙 2024-11-22 12:18:37

RMS 不适合存储照片。因为RMS是为小量存储而设计的。您无法处理大量数据。更好的是,您可以从手机内存或存储卡中读取。另外,如何在没有应用程序的情况下拍摄当前拍摄的照片?

编辑:

您可以开发用于拍照的应用程序< /a> 并将其存储在 RMS 中(但不是大量)或通过调用 网络服务

RMS is not good for storing the Photo's. Because RMS designed for small amount of storage. You can't handle huge amount of data. Better you can read from phone memory or memory card. 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.

刘备忘录 2024-11-22 12:18:37

好的,我让应用程序通过命令启动相机:

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();

在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);
        }
    }

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

现在我不知道调用createThumbnail方法时,也就是调用Image.createImage之后,图像存储在哪里:有两个 createImage 调用,一个在 capture() 方法中,一个在 createThumbnail() 方法中。但我真正的问题是知道创建的图像的位置以及如何将其与银行客户端 recordStore id 关联。

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 :

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 :

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. But my real problem is to know the location of the created image and how to associate it with a banking-client recordStore id.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文