/**
* Sets the camera up to take preview images which are used for both preview
* and decoding. We detect the preview format here so that
* buildLuminanceSource() can build an appropriate LuminanceSource subclass.
* In the future we may want to force YUV420SP as it's the smallest, and the
* planar Y can be used for barcode scanning without a copy in some cases.
*/
void setDesiredCameraParameters(Camera camera) {
// Camera.Parameters parameters = camera.getParameters();
// Log.d(TAG, "Setting preview size: " + cameraResolution);
// parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
// setFlash(parameters);
// setZoom(parameters);
// //setSharpness(parameters);
// //modify here
// camera.setDisplayOrientation(90);
// camera.setParameters(parameters);
Camera.Parameters parameters = camera.getParameters();
List<Size> supportedPreviewSizes = parameters
.getSupportedPreviewSizes();
int position = 0;
if (supportedPreviewSizes.size() > 2) {
position = supportedPreviewSizes.size() / 2 + 1;// supportedPreviewSizes.get();
} else {
position = supportedPreviewSizes.size() / 2;
}
int width = supportedPreviewSizes.get(position).width;
int height = supportedPreviewSizes.get(position).height;
Log.d(TAG, "Setting preview size: " + cameraResolution);
camera.setDisplayOrientation(90);
cameraResolution.x = width;
cameraResolution.y = height;
parameters.setPreviewSize(width, height);
setFlash(parameters);
setZoom(parameters);
// setSharpness(parameters);
camera.setParameters(parameters);
}
最后大喊一声:开源万岁!!!
转载请注明原文链接。 文中有不妥或者错误的地方还望指出,以免误人子弟。 再次感谢您耐心的读完本篇文章。