【发布时间】:2011-05-05 15:03:43
【问题描述】:
在我的应用程序中,我正在从它的颜色代码创建一个位图,如下所示:
int width=getImageWidth();
int height=getImageHeight();
int[] array=getbitmap();
int[] colorsAsIntegers = new int[width*height];
int i = 0;
int j = 0;
while (i<width*height*4) {
colorsAsIntegers[j] = Color.argb(array[i], array[i+1], array[i+2],
array[i+3]);
i += 4;
j++;
}
myBitmap=Bitmap.createBitmap(colorsAsIntegers,
width,
height,
Bitmap.Config.ARGB_8888);
而且我经常遇到内存不足错误:( 那么如何使用 BitmapFactory 优化来避免这个问题呢? 因为我没有输入流或文件,所以我只有一个数组 包含我的像素
谢谢
【问题讨论】:
-
你的图片有多大?您遇到了哪些设备问题?
-
我们得到这个错误时并不是一直在创建位图。 stackoverflow.com/a/18625792/2403532
标签: android memory bitmap out-of-memory