获取快照始终产生相同的值

发布于 2024-08-21 20:10:05 字数 208 浏览 9 评论 0原文

我有这段代码:

byte[] snap = ((VideoControl) player).getSnapshot("encoding=jpeg");

,它从相机获取快照。现在,经过一些处理后,它会生成正确的图像。奇怪的是,当我调试这行代码时,即使生成的图像不同,它在字段中始终具有相同的值。有什么想法吗?

问候修剪

I have this piece of code:

byte[] snap = ((VideoControl) player).getSnapshot("encoding=jpeg");

, which gets a snapshot from the camera. Now, after a little processing it produces correct image. The weird part is, that when I debug this line of code, it always has the same value in the field even when the resulting image is different. Any ideas why?

Regards Trim

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

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

发布评论

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

评论(4

残花月 2024-08-28 20:10:05

确保您查看的数据位于数组内部,而不是数组的内存地址(不一定需要更改)。

我希望这有帮助,

祝你好运

Make sure the data you view is inside the array and not the memory address of the array (which doesn't need necessarily to change).

I hope this helps,

Good Luck

别挽留 2024-08-28 20:10:05

也许需要澄清一下……什么在什么“领域”具有“相同的价值”?

听起来就像您将字节数组转换为图像。然后,当您再次调用 getSnapshot 时,您会得到相同的字节数组但不同的图像吗?

也许尝试 getSnapshot(null)。

比如:

        byte[] data = null;

        try {
            data = video.getSnapshot(null);
        } catch (MediaException ex) {
            ex.printStackTrace();
        }

        if(data != null)
        {
            img = Image.createImage(data, 0, data.length);
        }

你如何“调试”?模拟器?设备上?什么设备?

上面的代码适用于我的 K800i。

Perhaps some clarity is needed... what has the 'same value' in what 'field'?

Sounds like you take that byte array and turn it into an image. Then when you call getSnapshot again you get the same byte array but a different image?

Perhaps try getSnapshot(null).

Something like:

        byte[] data = null;

        try {
            data = video.getSnapshot(null);
        } catch (MediaException ex) {
            ex.printStackTrace();
        }

        if(data != null)
        {
            img = Image.createImage(data, 0, data.length);
        }

How are you 'debugging'? Emulator? On-device? What device?

The above code works for me on a K800i.

陪你到最终 2024-08-28 20:10:05

您确定 getSnapshot() 返回 VideoControl 吗?仔细检查一下。

Are you sure getSnapshot() returns a VideoControl? Double check that.

不再让梦枯萎 2024-08-28 20:10:05

经过广泛的搜索,我发现我错了,对于误导性的问题我深表歉意。然而,使用encoding=jpeg时,这些数组实际上只有一小部分不同,但使用其他编码时,它们确实有很大不同。再次,我对这个问题感到抱歉,因为我没有首先以困难的方式验证它。

After extensive search I have found I was wrong and I do apologize for misguiding question. However, with the encoding=jpeg those arrays really differ only in a small part, but with another encodings they do differ extensively. Again, sorry for this question when I didn't verify it the hard way first.

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