android.hardware.Camera.PictureCallback Java Examples

The following examples show how to use android.hardware.Camera.PictureCallback. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Tutorial3View.java    From marvel with MIT License 6 votes vote down vote up
public void takePicture(final String fileName) {
    Log.i(TAG, "Tacking picture");
    PictureCallback callback = new PictureCallback() {

        private String mPictureFileName = fileName;

        @Override
        public void onPictureTaken(byte[] data, Camera camera) {
            Log.i(TAG, "Saving a bitmap to file");
            Bitmap picture = BitmapFactory.decodeByteArray(data, 0, data.length);
            try {
                FileOutputStream out = new FileOutputStream(mPictureFileName);
                picture.compress(Bitmap.CompressFormat.JPEG, 90, out);
                picture.recycle();
                mCamera.startPreview();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    };

    mCamera.takePicture(null, null, callback);
}
 
Example #2
Source File: AndroidCameraAgentImpl.java    From Camera2 with Apache License 2.0 5 votes vote down vote up
CaptureCallbacks(ShutterCallback shutter, PictureCallback raw, PictureCallback postView,
        PictureCallback jpeg) {
    mShutter = shutter;
    mRaw = raw;
    mPostView = postView;
    mJpeg = jpeg;
}
 
Example #3
Source File: AndroidCameraAgentImpl.java    From Camera2 with Apache License 2.0 5 votes vote down vote up
public void requestTakePicture(
        final ShutterCallback shutter,
        final PictureCallback raw,
        final PictureCallback postView,
        final PictureCallback jpeg) {
    final CaptureCallbacks callbacks = new CaptureCallbacks(shutter, raw, postView, jpeg);
    obtainMessage(CameraActions.CAPTURE_PHOTO, callbacks).sendToTarget();
}
 
Example #4
Source File: Controller.java    From droidel with Apache License 2.0 5 votes vote down vote up
@Override
   public void onConfigurationChanged(Configuration newConfig) {
     if (mCamera != null) {
       PictureCallback cb = new PictureCallback() {
  @Override
  public void onPictureTaken(byte[] data, Camera camera) {}
};
mCamera.takePicture(null, null, cb);
     }
   }
 
Example #5
Source File: Controller.java    From droidel with Apache License 2.0 5 votes vote down vote up
@Override
   public void onConfigurationChanged(Configuration newConfig) {
     if (mCamera != null) {
       PictureCallback cb = new PictureCallback() {
  @Override
  public void onPictureTaken(byte[] data, Camera camera) {}
};
mCamera.takePicture(null, null, cb);
     }
   }
 
Example #6
Source File: Controller.java    From droidel with Apache License 2.0 5 votes vote down vote up
@Override
   public void onConfigurationChanged(Configuration newConfig) {
     if (mCamera != null) {
       PictureCallback cb = new PictureCallback() {
  @Override
  public void onPictureTaken(byte[] data, Camera camera) {}
};
mCamera.takePicture(null, null, cb);
     }
   }
 
Example #7
Source File: Controller.java    From droidel with Apache License 2.0 5 votes vote down vote up
@Override
   public void onConfigurationChanged(Configuration newConfig) {
     if (mCamera != null) {
       PictureCallback cb = new PictureCallback() {
  @Override
  public void onPictureTaken(byte[] data, Camera camera) {}
};
mCamera.takePicture(null, null, cb);
     }
   }
 
Example #8
Source File: Controller.java    From droidel with Apache License 2.0 5 votes vote down vote up
@Override
   public void onConfigurationChanged(Configuration newConfig) {
     if (mCamera != null) {
       PictureCallback cb = new PictureCallback() {
  @Override
  public void onPictureTaken(byte[] data, Camera camera) {}
};
mCamera.takePicture(null, null, cb);
     }
   }
 
Example #9
Source File: Controller.java    From droidel with Apache License 2.0 5 votes vote down vote up
@Override
   public void onConfigurationChanged(Configuration newConfig) {
     if (mCamera != null) {
       PictureCallback cb = new PictureCallback() {
  @Override
  public void onPictureTaken(byte[] data, Camera camera) {}
};
mCamera.takePicture(null, null, cb);
     }
   }
 
Example #10
Source File: AutoFocusManager.java    From Camdroid with Apache License 2.0 5 votes vote down vote up
public synchronized void takePicture(PictureCallback callback) {
    if (this.isFocused()) {
        try {
            this.camera.setPreviewCallback(null);
            this.camera.takePicture(this.shutterCallback, null, callback);
        } catch (RuntimeException re) {
            Log.w(TAG, "Unexpected exception while takePicture", re);
        }
    } else {
        this.pictureCallback = callback;
        this.takePicture = true;
    }
}
 
Example #11
Source File: AndroidCameraAgentImpl.java    From Camera2 with Apache License 2.0 4 votes vote down vote up
@Override
public void takePicture(
        final Handler handler, final CameraShutterCallback shutter,
        final CameraPictureCallback raw, final CameraPictureCallback post,
        final CameraPictureCallback jpeg) {
    final PictureCallback jpegCallback = new PictureCallback() {
        @Override
        public void onPictureTaken(final byte[] data, Camera camera) {
            if (mCameraState.getState() != AndroidCameraStateHolder.CAMERA_CAPTURING) {
                Log.w(TAG, "picture callback returning when not capturing");
            } else {
                mCameraState.setState(AndroidCameraStateHolder.CAMERA_IDLE);
            }
            handler.post(new Runnable() {
                @Override
                public void run() {
                    jpeg.onPictureTaken(data, AndroidCameraProxyImpl.this);
                }
            });
        }
    };

    try {
        mDispatchThread.runJob(new Runnable() {
            @Override
            public void run() {
                // Don't bother to wait since camera is in bad state.
                if (getCameraState().isInvalid()) {
                    return;
                }
                mCameraState.waitForStates(AndroidCameraStateHolder.CAMERA_IDLE |
                        AndroidCameraStateHolder.CAMERA_UNLOCKED);
                mCameraHandler.requestTakePicture(ShutterCallbackForward
                                .getNewInstance(handler, AndroidCameraProxyImpl.this, shutter),
                        PictureCallbackForward
                                .getNewInstance(handler, AndroidCameraProxyImpl.this, raw),
                        PictureCallbackForward
                                .getNewInstance(handler, AndroidCameraProxyImpl.this, post),
                        jpegCallback
                );
            }
        });
    } catch (final RuntimeException ex) {
        mCameraAgent.getCameraExceptionHandler().onDispatchThreadException(ex);
    }
}
 
Example #12
Source File: CameraContainer.java    From LLApp with Apache License 2.0 4 votes vote down vote up
@Override
public void takePicture(PictureCallback callback,
		TakePictureListener listener) {
	mCameraView.takePicture(callback,listener);
}
 
Example #13
Source File: CameraView.java    From LLApp with Apache License 2.0 4 votes vote down vote up
@Override
public void takePicture(PictureCallback callback,CameraContainer.TakePictureListener listener){
	mCamera.takePicture(null, null, callback);
}
 
Example #14
Source File: CameraPreviewView.java    From Camdroid with Apache License 2.0 4 votes vote down vote up
public void takePicture(PictureCallback callback) {
    if (this.mAutoFocusManager != null) {
        this.mAutoFocusManager.takePicture(callback);
    }
}
 
Example #15
Source File: CameraOperation.java    From LLApp with Apache License 2.0 2 votes vote down vote up
/**  
 *  拍照
 *  @param callback 拍照回调函数 
 *  @param listener 拍照动作监听函数  
 */
public void takePicture(PictureCallback callback, CameraContainer.TakePictureListener listener);