本文整理汇总了C++中CameraParameters::getSupportedPreviewSizes方法的典型用法代码示例。如果您正苦于以下问题:C++ CameraParameters::getSupportedPreviewSizes方法的具体用法?C++ CameraParameters::getSupportedPreviewSizes怎么用?C++ CameraParameters::getSupportedPreviewSizes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CameraParameters
的用法示例。
在下文中一共展示了CameraParameters::getSupportedPreviewSizes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSupportedVideoSizes
/*
* Query the camera to retrieve the supported video frame sizes
* and also to see whether CameraParameters::setVideoSize()
* is supported or not.
* @param params CameraParameters to retrieve the information
* @@param isSetVideoSizeSupported retunrs whether method
* CameraParameters::setVideoSize() is supported or not.
* @param sizes returns the vector of Size objects for the
* supported video frame sizes advertised by the camera.
*/
static void getSupportedVideoSizes(
const CameraParameters& params,
bool *isSetVideoSizeSupported,
Vector<Size>& sizes) {
*isSetVideoSizeSupported = true;
params.getSupportedVideoSizes(sizes);
if (sizes.size() == 0) {
ALOGD("Camera does not support setVideoSize()");
params.getSupportedPreviewSizes(sizes);
*isSetVideoSizeSupported = false;
}
}
示例2: getNumberOfCameras
NS_IMETHODIMP
GonkCameraInputStream::Init(nsACString& aContentType, nsCaptureParams* aParams)
{
if (XRE_GetProcessType() != GeckoProcessType_Default)
return NS_ERROR_NOT_IMPLEMENTED;
mContentType = aContentType;
mWidth = aParams->width;
mHeight = aParams->height;
mCamera = aParams->camera;
PRUint32 maxNumCameras = getNumberOfCameras();
if (maxNumCameras == 0)
return NS_ERROR_FAILURE;
if (mCamera >= maxNumCameras)
mCamera = 0;
mHardware = CameraHardwareInterface::openCamera(mCamera);
if (!mHardware)
return NS_ERROR_FAILURE;
mHardware->setCallbacks(NULL, GonkCameraInputStream::DataCallback, NULL, this);
mHardware->enableMsgType(CAMERA_MSG_PREVIEW_FRAME);
CameraParameters params = mHardware->getParameters();
printf_stderr("Preview format : %s\n", params.get(params.KEY_SUPPORTED_PREVIEW_FORMATS));
Vector<Size> previewSizes;
params.getSupportedPreviewSizes(previewSizes);
// find the available preview size closest to the requested size.
PRUint32 minSizeDelta = PR_UINT32_MAX;
PRUint32 bestWidth = mWidth;
PRUint32 bestHeight = mHeight;
for (PRUint32 i = 0; i < previewSizes.size(); i++) {
Size size = previewSizes[i];
PRUint32 delta = abs(size.width * size.height - mWidth * mHeight);
if (delta < minSizeDelta) {
minSizeDelta = delta;
bestWidth = size.width;
bestHeight = size.height;
}
}
mWidth = bestWidth;
mHeight = bestHeight;
params.setPreviewSize(mWidth, mHeight);
// try to set preferred image format
params.setPreviewFormat("yuv420p");
params.setPreviewFrameRate(mFps);
mHardware->setParameters(params);
params = mHardware->getParameters();
mFps = params.getPreviewFrameRate();
mIs420p = !strcmp(params.getPreviewFormat(), "yuv420p");
mHardware->startPreview();
mClosed = false;
return NS_OK;
}