问题描述
我正在使用自定义相机并且工作正常,但问题是图像以非常低(差)的质量保存.为了克服它,我尝试了所有建议和实现.喜欢,
I am using custom camera and working fine but the issue is image is saving with very low (poor) quality. To overcome with it , i have tried all suggestions and implementations. Like ,
parameters.setJpegQuality(100);
parameters.setPictureFormat(ImageFormat.JPEG);
这不起作用.之后我用过
this is not working. After that i have used
List<Size> sizes = cameraParams.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);
}
cameraParams.setPictureSize(mPictureSize.width, mPictureSize.height);
这也行不通.它的质量仍然很差.
This is also not working. Its saving with poor quality still.
注意:相机预览显示正确且质量良好,但问题在于将捕获的图像保存到 sdcard 文件夹时.
Note : Camera preview is showing proper with good quality but the issue is when saving captured image to sdcard folder.
高级帮助将不胜感激!
推荐答案
我的问题终于解决了.
在这里,我在捕获图像之前为相机预览设置 parameters
Here I was setting parameters
for camera preview before i was capturing the image
public void takePicture() {
mCamera.takePicture(new ShutterCallback() {
@Override
public void onShutter() {
}
}, new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
}
}, new PictureCallback() {
@Override
public void onPictureTaken(final byte[] data, Camera camera) {
data1 = data;
if (mCamera != null) {
mCamera.stopPreview();
}
}
});
}
所以在我在片段中调用这个函数之前,我已经在这个方法之前设置了参数.
So before i called this function in my fragment i have set parameters before this method.
mPreview.setParams(params);// This was the mistake what i have done !
mPreview.takePicture();
去掉mPreview.setParams(params);
这篇关于使用自定义相机的图像质量很差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!