我建立了一个自定义的摄像头应用程序,我试图改变所拍摄影像的resoloution。我看过周围,这可能取决于Android系统的手机或版本?
上我知道它们设置使用 setParameters
但就是不知道如何设置实际工作resoloution工作在所有手机。我想为我的应用程序的力量,否则关闭它是那种小。当我使用一个测试图片的640x348这部作品让周围的尺寸/ resoloution将是完美的。
这可能是更容易使用 setPictureSize
?
公共无效surfaceCreated(SurfaceHolder持有者){
// TODO自动生成方法存根
相机= Camera.open();
尝试 {
Camera.Parameters参数= camera.getParameters();
如果(this.getResources()。getConfiguration()。方向!= Configuration.ORIENTATION_LANDSCAPE){
parameters.set(方向,肖像);
camera.setDisplayOrientation(90);
//取消注释为Android 2.0及以上
parameters.setRotation(90);
} 其他 {
parameters.set(方向,山水);
camera.setDisplayOrientation(0);
//取消注释为Android 2.0及以上
parameters.setRotation(0);
}
camera.setParameters(参数);
camera.set previewDisplay(保持器);
}赶上(IOException异常除外){
camera.release();
}
camera.start preVIEW();
}
解决方案
没有 setResolution()
,只有 setPictureSize()
。使用 getSupportedPictureSizes()
在 Camera.Parameters
来找到你想要的大小,或利用这些信息来填充的ListView
或微调
或东西来选择所需的大小用户。 这里是最近更新为使用 getSupportedPictureSizes一个样本项目()
来寻找最小支持的分辨率和使用。
I have built a custom Camera App and I am trying to change the resoloution of the image that is took. I have read around that this could depend on the phone or version of Android?
I know they are set using the setParameters
but just dont know how to set the actuall resoloution to work on all phones. I am wanting it to be kind of small as my app force closes otherwise. When I use a test picture at 640x348 this works so around that size/resoloution would be perfect.
It may be easier to use setPictureSize
?
public void surfaceCreated(SurfaceHolder holder) {
// TODO Auto-generated method stub
camera = Camera.open();
try {
Camera.Parameters parameters = camera.getParameters();
if (this.getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE) {
parameters.set("orientation", "portrait");
camera.setDisplayOrientation(90);
// Uncomment for Android 2.0 and above
parameters.setRotation(90);
} else {
parameters.set("orientation", "landscape");
camera.setDisplayOrientation(0);
// Uncomment for Android 2.0 and above
parameters.setRotation(0);
}
camera.setParameters(parameters);
camera.setPreviewDisplay(holder);
} catch (IOException exception) {
camera.release();
}
camera.startPreview();
}
解决方案
There is no setResolution()
, only setPictureSize()
. Use getSupportedPictureSizes()
on Camera.Parameters
to find the size you want, or use that information to populate a ListView
or Spinner
or something for the user to choose the desired size. Here is a sample project recently updated to use getSupportedPictureSizes()
to find the smallest supported resolution and use that.
相关推荐
最新文章