Android的定制照相机质量 [英] Android Custom Camera Quality
问题描述
我用下面的参数我自定义相机
I am using the following parameters for my custom camera
mCamera = getCameraInstance();
params = mCamera.getParameters();
params.setFlashMode(Camera.Parameters.FLASH_MODE_AUTO);
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
params.setSceneMode(Camera.Parameters.SCENE_MODE_AUTO);
params.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_AUTO);
params.setExposureCompensation(0);
params.setPictureFormat(ImageFormat.JPEG);
params.setJpegQuality(100);
params.setRotation(90);
List<Size> sizes = params.getSupportedPictureSizes();
Camera.Size size = sizes.get(0);
params.setPictureSize(size.width, size.height);
mCamera.setParameters(params);
和拍摄照片后,图像的质量也相当不错。我在使用自动对焦和闪光灯。
And after a photo is taken, the quality of the image is quite bad. I have autofocus and flash in use.
这是我拍摄照片的方法。
This is my method for taking the photo..
mCamera.autoFocus(new Camera.AutoFocusCallback() {
ShutterCallback shutterCallback = new ShutterCallback() {
@Override
public void onShutter() {
AudioManager mgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
mgr.playSoundEffect(AudioManager.FLAG_PLAY_SOUND);
}
};
PictureCallback pictureCallback = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data,
Camera camera) {
...
}
};
public void onAutoFocus(boolean success, Camera camera) {
mCamera.takePicture(shutterCallback,
null, null, pictureCallback);
}
});
时,闪光灯不会闪光(我使用自动闪光),房间我是光线充足是它特别坏..
It is especially bad when the flash doesn't fire (I'm using auto flash) and the room I'm in is well lit..
推荐答案
当您使用 getSupportedPictureSizes()
,它不一定以任何顺序返回。它可能在 sizes.get返回一个可怕的尺寸(0)
。如果你想要最好的质量,你应该比较他们找到的最大尺寸。是这样的:
When you use getSupportedPictureSizes()
, it doesn't necessarily return them in any order. It's probably returning a horrible size in sizes.get(0)
. You should compare them to find the biggest size if you want the best quality. Something like:
List<Size> sizes = params.getSupportedPictureSizes();
Camera.Size size = sizes.get(0);
for(int i=0;i<sizes.size();i++)
{
if(sizes.get(i).width > size.width)
size = sizes.get(i);
}
params.setPictureSize(size.width, size.height);
这篇关于Android的定制照相机质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!