码迷,mamicode.com
首页 > 移动开发 > 详细

Android自定义照相机注意事项

时间:2014-05-04 18:26:02      阅读:422      评论:0      收藏:0      [点我收藏+]

标签:android   style   blog   class   code   java   

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自定义照相机注意事项

标签:android   style   blog   class   code   java   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!