I have the following code:
Bitmap bitmap = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_4444);
for (int y = 0; y < HEIGHT; y++) {
for (int x = 0; x < WIDTH; x++) {
int index = y * WIDTH + x;
bitmap.setPixel(x, y, Color.argb(255, 0, mask[index],0)); // mask is an array of int between 0 and 255
}
}
It works properly: I get my bitmap but...this code is really extremely slow.
I tried to replace it with:
Bitmap bitmap = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_4444);
bitmap.setPixels(mask, 0, WIDTH, 0, 0, WIDTH, HEIGHT);
but this is not working. I get a black image.
Anybody can help ?
Thanks !
maskexactly?setPixelsis expecting an array of color ints. In the loop version, you create the color from the mask value, but in the other version, you don't.