0

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 !

2
  • 1
    What is mask exactly? setPixels is 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. Commented Oct 14, 2020 at 22:27
  • Thanks a lot ! I was probably a litlle bit tired on yesterday evening :) Yes, I need to replace the values of my array with colors ! Thanks. Commented Oct 15, 2020 at 8:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.