如何在android中压缩imageview的图像

嗨我想在我的视图中显示存储在SD卡中的3或4个图像,图像的大小约为1-2 MB.
我的问题是当我在imageview中使用image然后它会抛出内存异常
我在将图像解码为位图时创建了位和传递选项

02-26 13:16:54.946: ERROR/dalvikvm-heap(23410): 15980544-byte external allocation too large for this process.
02-26 13:16:54.946: ERROR/dalvikvm(23410): Out of memory: Heap Size=3407KB, Allocated=2801KB, Bitmap Size=15630KB, Limit=21884KB
02-26 13:16:54.946: ERROR/dalvikvm(23410): Trim info: Footprint=3463KB, Allowed Footprint=3655KB, Trimmed=248KB
02-26 13:16:54.946: ERROR/GraphicsJNI(23410): VM won't let us allocate 15980544 bytes
02-26 13:16:54.986: ERROR/AndroidRuntime(23410): FATAL EXCEPTION: main
02-26 13:16:54.986: ERROR/AndroidRuntime(23410): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
02-26 13:16:54.986: ERROR/AndroidRuntime(23410):     at android.graphics.BitmapFactory.nativeDecodeFile(Native Method)
02-26 13:16:54.986: ERROR/AndroidRuntime(23410):     at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:325)

任何人都可以帮助我解决我的问题
提前致谢

解决方法:

我找到了我的问题的解决方案有我的代码:

BitmapFactory.Options options = new BitmapFactory.Options();
options.inTempStorage = new byte[24*1024];  
options.inJustDecodeBounds = false;
options.inSampleSize=32;     
bmp1=BitmapFactory.decodeFile(filepath1,options);  
Bitmap b1=ThumbnailUtils.extractThumbnail(bmp1,30, 30);  
iv1.setImageBitmap(b);  
 if(bmp1!=null){  
   bmp1.recycle();
   }  
         bmp1=BitmapFactory.decodeFile(filepath1,options);
 Bitmap b2=ThumbnailUtils.extractThumbnail(bmp1,30, 30);  
 iv2.setImageBitmap(b2);  
if(bmp1!=null){  
 bmp1.recycle();
 }

同样地,我将它用于四个图像视图并设置图像而没有OOM异常

上一篇:android – ImageView OutofMemoryException


下一篇:java – Android:问题图像分辨率