I have an array of ARGB pixels:

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

I need from this create Bitmap that in result should look like this: enter image description here

How from this integer array I crate an image to put inside imageview?

I have tried:

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);
有帮助吗?

解决方案

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

should work.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top