• Did you know…

    You can extract the alpha, red, blue, and green channels of a hexadecimal color with simple bit shift and logical AND operations? Below are the operations to extract these channels from RGB and ARGB color formats.

    RGB Channel Extraction - 24 bits

    // 24 bit color
    var color : uint = 0xff0000;
    
    var R : Number = color >> 16;
    var G : Number = ( color >> 8 ) & 0xff;
    var B : Number = color & 0xff;
    

    ARBG Channel Extraction - 32 bits

    // 32 bit color with alpha channel
    var color : uint = 0xffc7c8c9;
    
    var A : Number = ( color >> 24 ) & 0xff;
    var R : Number = ( color >> 16 ) & 0xff;
    var G : Number = ( color >> 8 ) & 0xff;
    var B : Number = color & 0xff;
    
    This entry was posted on Saturday, January 17th, 2009 at 2:41 pm and is filed under Flex, QueueTip. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
  • 0 Comments

    Take a look at some of the responses we've had to this article.

  • Post a Comment

    Let us know what you thought.

  • Name:

    Email (required):

    Website:

    Message: