Thursday 22 May 2014

Idea behind setting a color to transparent

Incredibly fascinating but works:

To set a color to transparent, we need to :

1. First render the color in 4 channel ARGB model

A (alpha channel) -> MSB  (bits 31-24)

R (Red) -> (bits 23 - 16)

G (Green) -> (bits 15 - 8)

B (Blue) -> (bits 7 to 0)

2. Then AND the ARGB color (argb) with 0x00FFFFFF and voila there you are!

What this does is maintains the color itself in RGB model while setting the alpha channel to zero.

In Computer Graphics, what all an zero alpha channel means is do not render the color! This functions like a directive to image formats like .png giving it the flexibility to either render or not render a specific color. Also note that JPEG cannot handle color transparency for its color model consists of 3 channels only (RGB).






No comments:

Post a Comment