
嗨我想在我的视图中显示存储在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=21884KB02-26 13:16:54.946: ERROR/dalvikvm(23410): Trim info: Footprint=3463KB, Allowed Footprint=3655KB, Trimmed=248KB02-26 13:16:54.946: ERROR/GraphicsJNI(23410): VM won't let us allocate 15980544 bytes02-26 13:16:54.986: ERROR/AndroIDRuntime(23410): FATAL EXCEPTION: main02-26 13:16:54.986: ERROR/AndroIDRuntime(23410): java.lang.OutOfMemoryError: bitmap size exceeds VM budget02-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的图像全部内容,希望文章能够帮你解决如何在android中压缩imageview的图像所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)