Android自定义照相机注意事项

1.设置预览方向myCamera.setDisplayOrientation(90)

2.设置照片方向parameters.setRotation(90);

3.设置预览显示和照片的分辨率 

// 设置照片分辨率
		List<Camera.Size> previewSizeList = parameters
				.getSupportedPreviewSizes();
		int previewWidth = 0;
		int previewHeight = 0;
		for (int i = 0; i < previewSizeList.size() - 1; i++) {
			previewWidth = previewSizeList.get(i).width;
			previewHeight = previewSizeList.get(i).height;
			int nextWidth = previewSizeList.get(i + 1).width;
			int nextHeight = previewSizeList.get(i + 1).height;
			if (previewWidth < nextWidth) {
				previewWidth = nextWidth;
			}
			if (previewHeight < nextHeight) {
				previewHeight = nextHeight;
			}
		}
		previewWidth = previewWidth>previewSizeList.get(0).width?previewWidth:previewSizeList.get(0).width;
		previewHeight = previewHeight>previewSizeList.get(0).height?previewHeight:previewSizeList.get(0).height;
		parameters.setPreviewSize(previewWidth, previewHeight);

		List<Camera.Size> supportedPictureSizesList = parameters
				.getSupportedPictureSizes();
		int supportedPictureWidth = 0;
		int supportedPictureHeight = 0;
		for (int i = 0; i < supportedPictureSizesList.size() - 1; i++) {
			supportedPictureWidth = supportedPictureSizesList.get(i).width;
			supportedPictureHeight = supportedPictureSizesList.get(i).height;
			int nextWidth = supportedPictureSizesList.get(i + 1).width;
			int nextHeight = supportedPictureSizesList.get(i + 1).height;
			if (supportedPictureWidth < nextWidth) {
				supportedPictureWidth = nextWidth;
			}
			if (supportedPictureHeight < nextHeight) {
				supportedPictureHeight = nextHeight;
			}
		}
		supportedPictureWidth = supportedPictureWidth>supportedPictureSizesList.get(0).width ?supportedPictureWidth:supportedPictureSizesList.get(0).width;
		supportedPictureHeight = supportedPictureHeight>supportedPictureSizesList.get(0).height ?supportedPictureHeight:supportedPictureSizesList.get(0).height;
		parameters
				.setPictureSize(supportedPictureWidth, supportedPictureHeight);

Android自定义照相机注意事项,,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。