此处未显示图片。它在两天前工作,但我做了一些改变,出了点问题。这是我在jpeg Callback的onPictureTaken(byte []数据,Camera camera)方法中放置的代码。 logcat显示onPicture Taken Text但不显示前两个文本“callback recieved null data”和“bitmap not created”
预览是线性布局,其高度和宽度都与父级匹配。
输出显示空白屏幕。
capture.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
captureStatus = 1 ;
Camera.PictureCallback rawCallback = new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
// TODO Auto-generated method stub
if (data == null) {
System.out.println("callback decieved null data");
}
mCamera = mPreview.stopCamera();
picture = BitmapFactory.decodeByteArray(data, 0, data.length, null);
Matrix mat = new Matrix();
mat.postRotate(90);
Bitmap newBitmap = Bitmap.createBitmap(picture, 0, 0, picture.getWidth(), picture.getHeight(), mat, true) ;
pic = new ImageView(c);
pic.setImageBitmap(newBitmap);
preview.removeAllViews();
preview.addView(pic);
preview.requestLayout();
System.out.println("On picture taken");
}
};
try {
mPreview.yCamera.takePicture(null, null,rawCallback);
} catch (Exception e) {
e.printStackTrace();
}
}
});