收到错误:外部分配太大,这一过程 [英] Getting error: external allocation too large for this process
问题描述
我想实现以下转变一个图像路径为位图,以显示我的活动code。我得到下面的错误。我已经尝试了很多不同的解决方案,但没有正在
<一个href=\"http://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue-while-loading-an-image-to-a-bitmap-object\">Android:奇怪的内存不足的问题,而加载图像为位图对象
<一个href=\"http://stackoverflow.com/questions/3331527/android-resize-a-large-bitmap-file-to-scaled-output-file\">Android:调整一个大的位图文件的缩放的输出文件
<一个href=\"http://stackoverflow.com/questions/2928002/outofmemoryerror-bitmap-size-exceeds-vm-budget-android\">OutOfMemoryError:位图大小超过VM预算: - Android电子
错误:
E / dalvikvm堆(19252):12742656字节外部分配太大,这一进程
的for(int i = 0; I&LT; numItems的;我++){ 文件imgFile =新的文件(photoPaths.get(I)); 如果(imgFile.exists())
{ 图像[i] = BitmapFactory.de codeFILE(imgFile.getAbsolutePath());
}
您可以考虑加载它们在一个更加公正,及时样的方式,或者使用 inSampleSize
位图工厂选项(例如,你传递一个 BitmapFactory.Options
到工厂 inSampleSize
集到,理想情况下,2的幂)。另外,请确保您设置 inPurgeable
真。
在这你是从的的ContentProvider
MediaStore
,也可以使用拉动这些图像的情况下< A HREF =http://developer.android.com/reference/android/provider/MediaStore.Images.Thumbnails.html相对=nofollow>缩略图。
也许你能告诉我们更多关于你的使用情况,以便我们能更好的帮助。
I am trying to implement the code below converting a image path into a bitmap to display on my activity. I am getting the below error. I have tried a bunch of different solutions but none are working
Android: Strange out of memory issue while loading an image to a Bitmap object
Android: Resize a large bitmap file to scaled output file
OutOfMemoryError: bitmap size exceeds VM budget :- Android
Error: E/dalvikvm-heap(19252): 12742656-byte external allocation too large for this process.
for(int i = 0; i < numItems; i++) {
File imgFile = new File(photoPaths.get(i));
if(imgFile.exists())
{
images[i] = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
}
You may consider loading them in a more just-in-time kind of approach, or using the inSampleSize
option of the bitmap factory (i.e., you'd pass a BitmapFactory.Options
in to the factory with inSampleSize
set to, ideally, a power of 2). Also make sure you set inPurgeable
true.
In the event that you are pulling these images from the MediaStore
's ContentProvider
, you can also use thumbnails.
Perhaps you can tell us more about your use case so we can better help.
这篇关于收到错误:外部分配太大,这一过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!