本文整理汇总了Java中android.hardware.Camera.startPreview方法的典型用法代码示例。如果您正苦于以下问题:Java Camera.startPreview方法的具体用法?Java Camera.startPreview怎么用?Java Camera.startPreview使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.hardware.Camera
的用法示例。
在下文中一共展示了Camera.startPreview方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: takePhoto
import android.hardware.Camera; //导入方法依赖的package包/类
public void takePhoto(){
Camera.ShutterCallback shutterCallback = new Camera.ShutterCallback() {
public void onShutter() {
Log.d(TAG, "onShutter: ");
}
};
Camera.PictureCallback jpegCallback = new Camera.PictureCallback() {
public void onPictureTaken(final byte[] data, final Camera camera) {
camera.startPreview();
Log.d(TAG, "onPictureTaken: ");
pictureTakenCallBack.saveAsBitmap(data);
}
};
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
camera.enableShutterSound(false);
}
camera.takePicture(shutterCallback, null, jpegCallback);
}
示例2: setUpSurfaceTextureInternal
import android.hardware.Camera; //导入方法依赖的package包/类
private void setUpSurfaceTextureInternal(final Camera camera, byte[] data) {
if (null == camera) {
log.error("setup camera failed, camera is null");
return;
}
int[] textures = new int[1];
GLES20.glGenTextures(1, textures, 0);
mSurfaceTexture = new SurfaceTexture(textures[0]);
try {
camera.addCallbackBuffer(data);
camera.setPreviewTexture(mSurfaceTexture);
camera.setPreviewCallbackWithBuffer(GPUImageRenderer.this);
camera.startPreview();
} catch (Exception e) {
log.error("setup camera failed, " + e.getMessage());
}
log.debug("setUpSurfaceTextureInternal " + camera + " " + data.length);
}
示例3: startPreview
import android.hardware.Camera; //导入方法依赖的package包/类
/**
* Asks the camera hardware to begin drawing preview frames to the screen.
*/
public synchronized void startPreview() {
Camera theCamera = camera;
if (theCamera != null && !previewing) {
theCamera.startPreview();
previewing = true;
autoFocusManager = new AutoFocusManager(context, camera);
}
}
示例4: startPreview
import android.hardware.Camera; //导入方法依赖的package包/类
/**
* Asks the camera hardware to begin drawing preview frames to the screen.
*/
public synchronized void startPreview() {
Camera theCamera = camera;
if (theCamera != null && !previewing) {
theCamera.startPreview();
previewing = true;
autoFocusManager = new AutoFocusManager(context, camera);
}
}
示例5: startPreview
import android.hardware.Camera; //导入方法依赖的package包/类
/**
* Asks the camera hardware to begin drawing preview frames to the screen.
*/
public synchronized void startPreview() {
Camera theCamera = camera;
if (theCamera != null && !previewing) {
theCamera.setDisplayOrientation(90);
theCamera.startPreview();
previewing = true;
autoFocusManager = new AutoFocusManager(context, camera);
}
}
示例6: startPreview
import android.hardware.Camera; //导入方法依赖的package包/类
@ReactMethod
public void startPreview(ReadableMap options) {
RCTCamera instance = RCTCamera.getInstance();
if (instance == null) return;
Camera camera = instance.acquireCameraInstance(options.getInt("type"));
if (camera == null) return;
camera.startPreview();
}
示例7: startPreview
import android.hardware.Camera; //导入方法依赖的package包/类
/**
* Asks the camera hardware to begin drawing preview frames to the screen.
*
* Must be called from camera thread.
*/
public void startPreview() {
Camera theCamera = camera;
if (theCamera != null && !previewing) {
theCamera.startPreview();
previewing = true;
autoFocusManager = new AutoFocusManager(camera, settings);
ambientLightManager = new AmbientLightManager(context, this, settings);
ambientLightManager.start();
}
}
示例8: startPreview
import android.hardware.Camera; //导入方法依赖的package包/类
/**
* Asks the camera hardware to begin drawing preview frames to the screen.
*/
public synchronized void startPreview() {
Camera theCamera = camera;
if (theCamera != null && !previewing) {
theCamera.startPreview();
previewing = true;
autoFocusManager = new AutoFocusManager(context, camera);
}
}
示例9: startPreview
import android.hardware.Camera; //导入方法依赖的package包/类
/**
* Asks the camera hardware to begin drawing preview frames to the screen.
*/
public synchronized void startPreview() {
Camera theCamera = camera;
if (theCamera != null && !previewing) {
theCamera.startPreview();
previewing = true;
autoFocusManager = new AutoFocusManager(camera);
}
}
示例10: setPreviewSize
import android.hardware.Camera; //导入方法依赖的package包/类
private boolean setPreviewSize(int width, int height, CallbackContext callbackContext) {
if(this.hasCamera(callbackContext) == false){
return true;
}
Camera camera = fragment.getCamera();
Camera.Parameters params = camera.getParameters();
params.setPreviewSize(width, height);
fragment.setCameraParameters(params);
camera.startPreview();
callbackContext.success();
return true;
}
示例11: setStartPreview
import android.hardware.Camera; //导入方法依赖的package包/类
/**
* 设置camera显示取景画面,并预览
*
* @param camera
*/
private void setStartPreview(Camera camera, SurfaceHolder holder) {
try {
if (null != camera) {
// 通过surfaceview显示取景画面
parameters = camera.getParameters(); // 获取各项参数
//矫正拍照之后图片的旋转的角度
if (!startFontCamera) {
parameters.setRotation(270);
} else {
parameters.setRotation(getPreviewDegree(CameraActivity.this));
}
// Size largestSize = getBestSupportedSize(parameters
// .getSupportedPreviewSizes());
// parameters.setPreviewSize(largestSize.width, largestSize.height);// 设置预览图片尺寸
Size largestSize = getBestSupportedSize(parameters
.getSupportedPictureSizes());// 设置捕捉图片尺寸
parameters.setPictureSize(largestSize.width, largestSize.height);
if (startFontCamera) {
//连续对焦
parameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
}
camera.setParameters(parameters);
camera.setPreviewDisplay(holder);
// 设置用于显示拍照影像的SurfaceHolder对象
camera.setDisplayOrientation(getPreviewDegree(CameraActivity.this));
camera.startPreview();
camera.cancelAutoFocus();//只有加上了这一句,才会自动对焦。
} else {
//
Toast.makeText(this, "无法打开摄像头,请检查是否给开启了相关权限", Toast.LENGTH_SHORT).show();
}
} catch (IOException e) {
}
}