2013-12-19 72 views
-1

我ARGB像素阵列:创建一个从像素的图像

for(int i = 0; i < 256; i++) 
{ 
black_to_white[i] = 0xFF000000 | (i << 0) | (i << 8) | (i << 16); 
} 

我从这个需要创建位图,在结果应该是这样的: enter image description here

如何从这个整数数组我箱子的图像放在imageview中?

我曾尝试:

int width = 256 
int height = 1 

Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); 
bitmap.setPixels(array, 0, width, 0, 0, width, height); 
+0

应该不是数组是black_to_white? – Nfear

+0

是的,它只是一个例子,它应该是 – Dim

回答

1
Bitmap.createBitmap(black_to_white, 256, 1, Bitmap.Config.ARGB_8888) 

应该工作。