Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> Android自定義照相機注意事項

Android自定義照相機注意事項

編輯:關於Android編程

1.設置預覽方向myCamera.setDisplayOrientation(90)

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

3.設置預覽顯示和照片的分辨率

// 設置照片分辨率
		List 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 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);

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved