本文整理汇总了Java中com.google.zxing.client.android.camera.CameraManager.setManualFramingRect方法的典型用法代码示例。如果您正苦于以下问题:Java CameraManager.setManualFramingRect方法的具体用法?Java CameraManager.setManualFramingRect怎么用?Java CameraManager.setManualFramingRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.zxing.client.android.camera.CameraManager
的用法示例。
在下文中一共展示了CameraManager.setManualFramingRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onResume
import com.google.zxing.client.android.camera.CameraManager; //导入方法依赖的package包/类
/**
* 启动相机预览与扫描,在Activity/Fragment的onResume方法中调用。
*/
public void onResume() {
if (checkCameraHardware()) {
mCameraManager = new CameraManager(this);
if (frameWidth > 0 && frameHeight > 0) {
mCameraManager.setManualFramingRect(frameWidth, frameHeight, frameTopOffset);
}
SurfaceHolder surfaceHolder = getHolder();
if (hasSurface) {
initCamera(surfaceHolder);
} else {
surfaceHolder.addCallback(this);
}
} else {
if (mOnBarcodeReadListener != null) {
mOnBarcodeReadListener.onCameraNotFound();
}
}
}
示例2: openDriver
import com.google.zxing.client.android.camera.CameraManager; //导入方法依赖的package包/类
private void openDriver(SurfaceHolder surfaceHolder) {
notifyListenerPrepareOpen();
if (surfaceHolder == null)
return;// 已经销毁
if (isOpen())
return;// 摄像头已经打开
if (Compat.checkSelfPermission(getContext(), Manifest.permission.CAMERA)
== PackageManager.PERMISSION_DENIED) {
mErrorCode = ERROR_CODE_1;
notifyListenerError();
return;
}
mCameraManager = new CameraManager(getContext());
if (mCameraId != OpenCameraInterface.NO_REQUESTED_CAMERA)
mCameraManager.setManualCameraId(mCameraId);
final int width = mScanWidth == ViewGroup.LayoutParams.MATCH_PARENT ? getWidth() :
(mScanWidth > getWidth() ? getWidth() : mScanWidth);
final int height = mScanHeight == ViewGroup.LayoutParams.MATCH_PARENT ? getHeight() :
(mScanHeight > getHeight() ? getHeight() : mScanHeight);
mCameraManager.setManualFramingRect(width, height);
try {
mCameraManager.openDriver(surfaceHolder);
mCameraManager.startPreview();
mScanHandler = new ScanHandler(resultListener, mBarcodeType, mBaseHints,
mCharacterSet, mCameraManager,
resultPointCallback);
} catch (Exception e) {
mErrorCode = ERROR_CODE_0;
notifyListenerError();
return;
}
mAmbientLightManager.resume();
notifyListenerOpened();
}