setParameters设置棕褐色时失败,但缩放工作正常 [英] setParameters failed when setting sepia, but zoom works fine

查看:343
本文介绍了setParameters设置棕褐色时失败,但缩放工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个使用相机的应用程序。当它启动时,它执行代码来检查相机的功能。我执行的一项检查如下:

I am making an app which employs the camera. When it starts up it executes code to check the capabilities of the camera. One check I do is the following:

    List<String> supported_colour_effects_list = java_recording_camera_parameters.getSupportedColorEffects();

    Mylog("There are "+supported_colour_effects_list.size()+" supported colour effects");
    for (int i = 0;i < supported_colour_effects_list.size();i++)
    {
        Mylog("Colour effect: ["+supported_colour_effects_list.get(i)+"]");
    }



当此代码执行时,我看到以下输出:

When this code executes, I see the following output:

I/xx(11517): There are 12 supported colour effects
I/xx(11517): Colour effect: [none]
I/xx(11517): Colour effect: [mono]
I/xx(11517): Colour effect: [negative]
I/xx(11517): Colour effect: [solarize]
I/xx(11517): Colour effect: [sepia]
I/xx(11517): Colour effect: [posterize]
I/xx(11517): Colour effect: [whiteboard]
I/xx(11517): Colour effect: [blackboard]
I/xx(11517): Colour effect: [aqua]
I/xx(11517): Colour effect: [emboss]
I/xx(11517): Colour effect: [sketch]
I/xx(11517): Colour effect: [neon]

然后程序继续,我可以查看相机看到的连续预览。如果我按一个按钮来启动以下代码...

The program then continues and I can view a continuous preview of what the camera sees. If I press a button to instigate the following code...

    java_recording_camera_parameters.setZoom(75);
    java_camera_for_recording.setParameters(java_recording_camera_parameters);

那么一切都正常工作,你可以看到预览图像突然放大。 java_recording_camera_parameters.setColorEffect(Camera.Parameters.EFFECT_SEPIA); java_recording_camera_parameters.setZoom(75); 我按下同一个按钮,然后得到以下错误...

then everything works exactly as expected, you can see the preview image suddenly zoom in. Bit if I swap the line java_recording_camera_parameters.setZoom(75); for java_recording_camera_parameters.setColorEffect(Camera.Parameters.EFFECT_SEPIA); then, when I press that same button then I get the following error...

W/System.err(4128): java.lang.RuntimeException: setParameters failed
W/System.err(4128):     at android.hardware.Camera.native_setParameters(Native Method)
W/System.err(4128):     at android.hardware.Camera.setParameters(Camera.java:1551)

我不知道为什么。

推荐答案

这是它是如何工作的(或不)。在某些设备上,一些声明为受支持的设置失败。有时它会与RuntimeException失败,但通常 - 默认:您在Galaxy Nexus上将预览大小设置为320x240,但回调会带回VGA帧。

This is how it works (or doesn't). On some devices some settings that are declared to be supported, fail. Sometimes it fails with RuntimeException, but often - silently: you set preview size to 320x240 on a Galaxy Nexus, but the callback brings back VGA frames.

某些设置不兼容与其他人:也许Sepia与您的预览大小不兼容,或者必须在预览停止时设置。

Some settings are not compatible with the others: maybe Sepia is not compatible with your preview size, or must be set while preview is stopped.

一个好的测试是看看是否可以选择棕褐色在同一设备上的内置相机应用程序中。

One good test would be to see if you can choose Sepia in the built-in camera app on the same device.

这篇关于setParameters设置棕褐色时失败,但缩放工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆