问题描述:

预览图像被拉伸变形

问题原因:

由于预览图像大小跟SurfaceView 大小不一致引起

解决方法:

获取系统支持的所有预览尺寸[getSupportedPictureSizes],然后再取一个比较接近的尺寸进行设置[setPreviewSize]

选择最佳尺寸方法:

private Point getBestCameraResolution(Camera.Parameters parameters, Point screenResolution){

float tmp = 0f;

float mindiff = 100f;

float x_d_y = (float)screenResolution.x / (float)screenResolution.y;

Size best = null;

List supportedPreviewSizes = parameters.getSupportedPreviewSizes();

for(Size s : supportedPreviewSizes){

tmp = Math.abs(((float)s.height/(float)s.width)-x_d_y);

if(tmp

mindiff = tmp;

best = s;

}

}

return new Point(best.width, best.height);

}

来自:http://blog.csdn.net/leeo1010/article/details/45566013

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐