内存不足的错误与导入图像图像、错误、内存不足

由网友(我敢碰她内衣就敢给她嫁衣)分享简介:我想加载图像在Android 背景= BitmapFactory.de codeResource(getResources(),R.drawable.hangmanbegin);背景= Bitmap.createScaledBitmap(背景下,screenx,screeny,假);图片为800 * 1280像素,所...

我想加载图像在Android

 背景= BitmapFactory.de codeResource(getResources(),R.drawable.hangmanbegin);
背景= Bitmap.createScaledBitmap(背景下,screenx,screeny,假);
 

图片为800 * 1280像素,所以如果我是正确的,应该用以防万一的内存空间3MB? 但我的堆从15MB增大到29MB只是在那个阶段,所以没有窗口或上下文泄露?

这怎么解释呢?恩你能做些什么呢?

日Thnx提前!

解决方案   

位图占用了大量的内存,尤其是丰富的图像,例如   照片。例如,在Galaxy Nexus的相机拍摄的照片   高达2592x1936像素(5百万像素)。如果位图构   采用的是ARGB_8888(从Android 2.3以后默认值),那么   加载此图像到内存大约需要的内存(2592 * 1936年* 4 19MB   字节),立刻用尽在某些设备上的每个应用程序的限制。

从 http://developer.android.com/training/displaying-bitmaps /index.html

信贷和它下面的方式来接近修复 http://stackoverflow.com/a/10127787/643500

I want to load an image on android

background = BitmapFactory.decodeResource(getResources(),R.drawable.hangmanbegin);    
background =  Bitmap.createScaledBitmap(background,screenx,screeny,false);
Adobe Illustrator CS6 导出图片格式的时候出现 内存不足的问题 请帮忙解决一下哦

The image is 800*1280 pixels , so if I'm correct it should use arround 3MB of memory space? But my heap grows from 15MB to 29MB just at that phase , so no window or context leaking?

How is this explained? en what can you do about it?

Thnx in advance!

解决方案

Bitmaps take up a lot of memory, especially for rich images like photographs. For example, the camera on the Galaxy Nexus takes photos up to 2592x1936 pixels (5 megapixels). If the bitmap configuration used is ARGB_8888 (the default from the Android 2.3 onward) then loading this image into memory takes about 19MB of memory (2592*1936*4 bytes), immediately exhausting the per-app limit on some devices.

from http://developer.android.com/training/displaying-bitmaps/index.html

credit and below it a way to approach a fix http://stackoverflow.com/a/10127787/643500

阅读全文

相关推荐

最新文章