2
我有一個應用程序,我需要將它們從相機中取出後將其保存到SD卡中。android中的java.lang.OutOfMemoryError保存從相機拍攝的照片
下面是代碼:
camera.takePicture(myShutterCallback, myPictureCallback_RAW,
myPictureCallback_JPG);
PictureCallback myPictureCallback_JPG = new PictureCallback() {
@Override
public void onPictureTaken(byte[] arg0, Camera arg1) {
Bitmap bitmapPicture = BitmapFactory.decodeByteArray(arg0, 0,
arg0.length);
FileOutputStream outStream = null;
try {
outStream = new FileOutputStream(UploadedFilename);
} catch (FileNotFoundException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
final Bitmap result = Bitmap.createScaledBitmap(bitmapPicture, 640,
480, false);
在此行中的代碼炸彈:
位圖bitmapPicture = BitmapFactory.decodeByteArray(爲arg0,0, arg0.length);
它說其:
異常類java.lang.OutOfMemoryError 源方法BitmapFactory.nativeDecodeByteArray()。
請幫助
看來你的圖片太大創建位圖。 –
請閱讀此處:http://stackoverflow.com/questions/1955410/bitmapfactory-oom-driving-me-nuts/ –