我们可以第3个参数中处理一下。
private PictureCallback pc2 = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
// TODO Auto-generated method stub
// 存储相片-Decode an immutable(不变的) bitmap from the specified byte
// array.
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length)
FileOutputStream out = null
try {
out = new FileOutputStream("/sdcard/pic_1.jpg")
BufferedOutputStream bos = new BufferedOutputStream(out)
bitmap.compress(CompressFormat.JPEG, 80, bos)// 压缩图片
bos.flush()
bos.close()
out.close()
iv.setImageBitmap(bitmap)//iv是一个imageView
stopCamera()// 关闭照相机
init()
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace()
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace()
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)