When I use an image as a background, then set the alpha values for all pixels in a second image to something low, then draw that image, I can see “through” the second image to the background, just as I would expect. Here, the mandrill is the second image, with alpha set to 0x40 for every pixel:
If I set alpha to 0x00 for the very first pixel, the entire mandrill becomes opaque:
I’m using Processing 3.5.4. Here’s my code:
PImage imgFace;
PImage imgMandrill;
void setup()
{
size(480, 480);
imgFace = loadImage("Face.png");
imgMandrill = loadImage("Mandrill.png");
imgMandrill.loadPixels();
for(int p = 0; p < imgMandrill.pixels.length; ++p)
{
imgMandrill.pixels[p] = (imgMandrill.pixels[p] & 0xFFFFFF) | 0x40000000;
}
imgMandrill.pixels[0] = imgMandrill.pixels[0] & 0xFFFFFF;
imgMandrill.updatePixels();
}
void draw()
{
background(imgFace);
image(imgMandrill, 0, 0);
}
I would have expected changing the alpha of one pixel, particularly the upper-left corner, to make virtually no visible difference. Indeed, if I set the alpha of any other pixel to zero, the faint mandrill looks the same as in the first image.
Why does setting the first pixel’s alpha to zero result in the entire image being drawn as though all alpha values were 255?