首页 > 移动平台 > 详细

Android自定义照相机注意事项

时间:2014-05-04 18:25:50      阅读:598      评论:0      收藏:0      [点我收藏+]

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自定义照相机注意事项,布布扣,bubuko.com

Android自定义照相机注意事项

原文:http://blog.csdn.net/android_farmer/article/details/24975819

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!