Domanda

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);
È stato utile?

Soluzione

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

should work.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top