调用系统照相机的takePicture,回调过来的图片,
// 拍照成功回调函数
private Camera.PictureCallback myPicCallback = new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
// 将得到的照片进行270度旋转,使其竖直
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
Matrix matrix = new Matrix();
matrix.preRotate(270);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
bitmap.getHeight(), matrix, true);
iv.setImageBitmap(bitmap);
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss")
.format(new Date());
// 创建并保存图片文件
File pictureFile = new File(getDir(), "IMG_" + timeStamp + ".jpg");
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.close();
Log.e("Tag","拍照成功");
openFacingFrontCamera();
} catch (Exception error) {
Log.e("Tag","拍照失败:"+error);
Log.i("Tag", "保存照片失败" + error.toString());
error.printStackTrace();
openFacingFrontCamera();
}
/* myCamera.stopPreview();
myCamera.release();
myCamera = null;*/
}
};
代码是这样的,在我自己的手机上看着挺正常的,但是放到客户的那种网络一体机,就出问题了,边缘发绿了,关键它用它内置的拍照app进行拍照,出来的照片没问题的,所以就觉着是不是我哪出问题了,求解个大神!!
图片就是这样的