首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RecordStore和手机拍摄的照片

RecordStore和手机拍摄的照片
EN

Stack Overflow用户
提问于 2011-06-15 14:39:12
回答 2查看 325关注 0票数 0

当用户用手机拍照时,我希望LWUIT获得一张特定的照片,并将其添加到记录库中,然后检索该照片。如何做到这一点呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-06-16 16:51:19

好的,我通过一个命令让应用程序启动摄像头:

代码语言:javascript
复制
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中:

代码语言:javascript
复制
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的代码如下:

代码语言:javascript
复制
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相关联。

票数 1
EN

Stack Overflow用户

发布于 2011-06-15 17:33:03

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

编辑:

您可以为taking the photo开发应用程序并将其存储在RMS(但不是大量)中,也可以通过调用web service将其存储在服务器中。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6353977

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档