Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualTheChubu

Posted 25 November 2012 - 07:44 PM

One question, how the pixels are composed?

Because you're doing an & with 0xFF (255 decimal, 11111111 binary) You're applying a mask.

The rightmost 8 bits of the mask will be set to 1, the rest to zero. So when you apply that mask to each pixel, you're going to get the rightmost 8 bits of the pixel unchanged (1 & something = something) and the rest set to 0.

If the pixel is 8 bits per channel, RGBA (Red, Green, Blue, Alpha, 32 bits in total). I *think* you're actually going to get rid of the 24 leftmost bits (RGB channels). You'd need a mask of 0xFFFFFF00 to get rid of the rightmost 8 bits. But that depends on what "pixel" actually contains.

EDIT: Huh, its ARGB actually. Still, you get only your rightmost color channel out of that mask. Everything to the left is zero'd. So instead of getting rid of RGB, you get rid of ARG and you're left only with B channel.

Anyway, I'm watching the tutorial and I think the guy is completely lost or it explained the whole issue pretty badly. You still have 32 bits, you cant erase 8 bits just like that. At most what you'd want to do is to set up every alpha to opaque, FF, 255, whatever. In that case you'd need an OR mask instead. pixel[i] | 0xFF000000. That way, the leftmost 8 bits (your alpha channel) always get set to 1 and the rest are unchanged.

#4TheChubu

Posted 25 November 2012 - 07:42 PM

One question, how the pixels are composed?

Because you're doing an & with 0xFF (255 decimal, 11111111 binary) You're applying a mask.

The rightmost 8 bits of the mask will be set to 1, the rest to zero. So when you apply that mask to each pixel, you're going to get the rightmost 8 bits of the pixel unchanged (1 & something = something) and the rest set to 0.

If the pixel is 8 bits per channel, RGBA (Red, Green, Blue, Alpha, 32 bits in total). I *think* you're actually going to get rid of the 24 leftmost bits (RGB channels). You'd need a mask of 0xFFFFFF00 to get rid of the rightmost 8 bits. But that depends on what "pixel" actually contains.

EDIT: Huh, its ARGB actually. Still, you get only your rightmost color channel out of that mask. Everything to the left is zero'd. So instead of getting rid of RGB, you get rid of ARG and you're left only with B channel.

Anyway, I'm watching the tutorial and I think the guy is completely lost. You still have 32 bits, you cant erase 8 bits just like that. At most what you'd want to do is to set up every alpha to opaque, FF, 255, whatever. In that case you'd need an OR mask instead. pixel[i] | 0xFF000000. That way, the leftmost 8 bits (your alpha channel) always get set to 1 and the rest are unchanged.

#3TheChubu

Posted 25 November 2012 - 06:21 PM

One question, how the pixels are composed?

Because you're doing an & with 0xFF (255 decimal, 11111111 binary) You're applying a mask.

The rightmost 8 bits of the mask will be set to 1, the rest to zero. So when you apply that mask to each pixel, you're going to get the rightmost 8 bits of the pixel unchanged (1 & something = something) and the rest set to 0.

If the pixel is 8 bits per channel, RGBA (32 bits in total). I *think* you're actually going to get rid of the 24 leftmost bits (RGB channels). You'd need a mask of 0xFFFFFF00 to get rid of the rightmost 8 bits. But that depends on what "pixel" actually contains.

#2TheChubu

Posted 25 November 2012 - 06:21 PM

One question, how the pixels are composed?

Because you're doing an & with 0xF (255 decimal, 11111111 binary) You're applying a mask.

The rightmost 8 bits of the mask will be set to 1, the rest to zero. So when you apply that mask to each pixel, you're going to get the rightmost 8 bits of the pixel unchanged (1 & something = something) and the rest set to 0.

If the pixel is 8 bits per channel, RGBA (32 bits in total). I *think* you're actually going to get rid of the 24 leftmost bits (RGB channels). You'd need a mask of 0xFFFFFF00 to get rid of the rightmost 8 bits. But that depends on what "pixel" actually contains.

#1TheChubu

Posted 25 November 2012 - 06:19 PM

One question, how the pixels are composed?

Because you're doing an & with 0xFF, 255, 11111111. You're applying a mask.

The rightmost 8 bits of the mask will be set to 1, the rest to zero. So when you apply that mask to each pixel, you're going to get the rightmost 8 bits of the pixel unchanged (1 & something = something) and the rest set to 0.

If the pixel is 8 bits per channel, RGBA. I *think* you're actually going to get rid of the 24 leftmost bits (RGB channels). You'd need a mask of 0xFFFFFF00 to get rid of the rightmost 8 bits. But that depends on what "pixel" actually contains.

PARTNERS