如何捕获自定义图像尺寸与相机中的android? [英] How to capture a custom image size with the camera in android?
问题描述
如何捕获的Android的一个正方形图像? 我想通过意图的android呼叫相机捕捉到的正方形图像(例如300×300像素),我该怎么办呢?
How to capture an square image in android? I want to capture an square image (such as 300x300 pixel) by calling Camera through intent in android, how can I do this?
推荐答案
使用的Camera.Size嵌套类
Use the Camera.Size nested class
<一个href="http://developer.android.com/reference/android/hardware/Camera.Size.html">http://developer.android.com/reference/android/hardware/Camera.Size.html
从Android参考:
From the android reference:
<一个href="http://developer.android.com/reference/android/hardware/Camera.html">http://developer.android.com/reference/android/hardware/Camera.html
类概述
Camera类用于设置图像捕获设置,启动/停止preVIEW,抓拍图片和检索视频编码帧。这个类是相机业务,其管理的实际摄像头硬件的客户端。
The Camera class is used to set image capture settings, start/stop preview, snap pictures, and retrieve frames for encoding for video. This class is a client for the Camera service, which manages the actual camera hardware.
请确保大小相机支持(并极有可能也不会)。如果不是这样,拍摄照片在最近的分辨率和裁剪或调整其大小。
Make sure that the size is supported by the camera (and most probably it won't). If not, take a picture at the closest resolution and crop it or resize it.
Camera myCamera = Camera.open(0);
List<Camera.Size> sizes = myCamera.getPArameters().getSupportedPictureSizes();
要了解相机的意图,在SO已经检查这些问题:
To learn about camera intents, check these questions already in SO:
这篇关于如何捕获自定义图像尺寸与相机中的android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!