From 99b18120c9454083ab011d560b93e752b0ff5016 Mon Sep 17 00:00:00 2001 From: Dylan McIntyre Date: Sun, 22 Jan 2017 20:17:50 -0500 Subject: [PATCH] Add image and video capture sections to README --- README.md | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 852adf31..b8b63b57 100644 --- a/README.md +++ b/README.md @@ -146,13 +146,35 @@ camera.setCameraListener(new CameraListener() { | `speed` | Freeze the `CameraView` preview and grab a `Bitmap` of the frame. | | `auto` | Default picture mode to `quality`, but fallback to `speed` if capturing is determined to be too slow. | -### Capturing images +### Capturing Images -Capturing photos +To capture an image just call `CameraView.capturePicture()`. Make sure you setup a `CameraListener` to handle the image callback. + +```java +camera.setCameraListener(new CameraListener() { + @Override + public void onPictureTaken(byte[] picture) { + super.onPictureTaken(picture); + + // Create a bitmap + Bitmap result = BitmapFactory.decodeByteArray(picture, 0, picture.length); + } +}); +``` ### Capturing Video -Capturing video +To capture video just call `CameraView.startRecordingVideo()` to start, and `CameraView.stopRecordingVideo()` to finish. Make sure you setup a `CameraListener` to handle the video callback. + +```java +camera.setCameraListener(new CameraListener() { + @Override + public void onVideoTaken(File video) { + super.onVideoTaken(video); + // The File parameter is an MP4 file. + } +}); +``` ## Automatic Permissions Behavior