2013-12-19 73 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) 

應該工作。