本文整理汇总了Java中android.hardware.Camera.PictureCallback类的典型用法代码示例。如果您正苦于以下问题:Java PictureCallback类的具体用法?Java PictureCallback怎么用?Java PictureCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PictureCallback类属于android.hardware.Camera包,在下文中一共展示了PictureCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: takePicture
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
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);
}
示例2: onClick
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.take_photo_fragment_take_photo_btn:
cameraManager.takePhoto(new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
Bitmap bitmap = BitmapUtil.toBitmap(data);
BitmapUtil.saveBitmapToFile(bitmap, Environment.getInstance().getMyDir() + "/" + new Date().getTime() + ".jpg", CompressFormat.JPEG);
Bundle bundle = new Bundle();
bundle.putParcelable("bitmap", bitmap);
setResult(bundle);
cameraManager.restartPreview();
}
});
break;
default:
break;
}
}
示例3: requestTakePicture
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
public void requestTakePicture(
final ShutterCallback shutter,
final PictureCallback raw,
final PictureCallback postView,
final PictureCallback jpeg) {
post(new Runnable() {
@Override
public void run() {
try {
mCamera.takePicture(shutter, raw, postView, jpeg);
} catch (RuntimeException e) {
// TODO: output camera state and focus state for debugging.
Log.e(TAG, "take picture failed.");
throw e;
}
}
});
}
示例4: take_picture
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
public void take_picture(String filename, PictureCallback callback)
{
picture_filename = filename;
picture_callback = callback;
mCamera.setPreviewCallback(null);
updateOrientation();
final CornerDetectionView this_ref=this;
mCamera.autoFocus(new Camera.AutoFocusCallback()
{
@Override
public void onAutoFocus(boolean success, Camera cam)
{
cam.takePicture(null, null, null, this_ref);
}
});
}
示例5: onConfigurationChanged
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
@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);
}
}
示例6: takePhoto
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
public void takePhoto(PictureCallback jpeg) {
DebugLog.d(TAG, "takePhoto()");
if (camera != null) {
camera.takePicture(null, null, jpeg);
}
}
示例7: takePicture
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
private void takePicture() {
mCamera.takePicture(
null,
null,
new PictureCallback() {
@Override
public void onPictureTaken(final byte[] jpegData, Camera camera) {
final Camera.Size size = camera.getParameters().getPictureSize();
Log.i(TAG, "Captured JPEG " + jpegData.length + " bytes (" + size.width + "x" + size.height + ")");
if (mImageListener != null) {
mCallbackHandler.post(
new Runnable() {
@Override
public void run() {
mImageListener.onJpegImageAvailable(jpegData, size.width, size.height);
}
}
);
}
if (mContinueTakingPictures) {
mCamera.startPreview();
takePicture();
}
}
}
);
}
示例8: takePicture
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
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;
}
}
示例9: takePicture
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
private void takePicture() {
PictureCallback mPicture = new PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
new MediaSaver().execute(data);
mCamera.startPreview();
}
};
mCamera.takePicture(null, null, mPicture);
}
示例10: setPictureListener
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
public void setPictureListener(PictureCallback listener) {
pictureListener = listener;
}
示例11: takePicture
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
@Override
public void takePicture(PictureCallback callback,
TakePictureListener listener) {
mCameraView.takePicture(callback,listener);
}
示例12: takePicture
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
@Override
public void takePicture(PictureCallback callback,CameraContainer.TakePictureListener listener){
mCamera.takePicture(null, null, callback);
}
示例13: takePicture
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
public void takePicture(PictureCallback callback) {
if (this.mAutoFocusManager != null) {
this.mAutoFocusManager.takePicture(callback);
}
}
示例14: setPictureCallback
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
public void setPictureCallback(PictureCallback pictureCallback) {
this.pictureCallback = pictureCallback;
}
示例15: takePicture
import android.hardware.Camera.PictureCallback; //导入依赖的package包/类
public void takePicture(final PictureCallback jpegCallback) {
if (null == camera) return;
camera.takePicture(null, null, jpegCallback);
}