Those are number in hex. In hex each digit represents 4 bits, so it takes 2 hex digits for one byte. In java an int is a 32 bit number (4 bytes). When people use an int to represent a color they typically use one byte per component. This works nicely because you can have Red, Green, Blue and a Apha fit nicely in an int. The order is usually ARGB. So, for the number 0x12345678 in hex "12" is the alpha component, "34" is the red, and so on.

To set the apha to 0 (completely transparent) you would set the alpha component to 0x00000000 in hex. The new line would look like:

pixels[ctr] = 0x00000000 | (pixels[ctr] & 0x00FFFFFF);

PS: by my math the 0x4F000000 would be 31% transparent, not 25% like previously claimed.

We have a color: pixels[ctr] . The first thing that happens is the bitwise and operator: "&" is used to effectivly remove the alpha component. It is really setting it to zero by only keeping the RGB components.

So now we have that color without an alpha and we are combining an alpha of 0x4F with the bitwise or operator: "|".

Finally we put the new color back in to the array.

One more time: We took a color, removed the alpha, and combined that color with a new alpha.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org