满意答案
huanagain
2018.01.31
采纳率:50% 等级:7
已帮助:1159人
|//自动聚焦
camera.autoFocus(new Camera.AutoFocusCallback() {
@Override
public void onAutoFocus(boolean success, Camera camera) {
camera.takePicture(null, null, mPicture);
Toast.makeText(CameraActivity.this, "拍照成功", Toast.LENGTH_SHORT).show();
}
});
//下面的回调方法很慢才得到图片数据
/**
* 拍照回调方法
*/
private Camera.PictureCallback mPicture = new Camera.PictureCallback() {
private Bitmap mBm;
@Override
public void onPictureTaken(byte[] data, Camera camera) {
// dialog显示图片
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
Mydialog mydialog = new Mydialog(CameraActivity.this,bitmap);
Window window = mydialog.getWindow();
WindowManager.LayoutParams lp = window.getAttributes();
window.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
lp.width = 1000;
lp.height = 700;
window.setAttributes(lp);
mydialog.show();
camera.startPreview();
}
};
00分享举报