You are here

function _image_captcha_hex_to_rgb in CAPTCHA 7

Same name and namespace in other branches
  1. 5.3 image_captcha/image_captcha.module \_image_captcha_hex_to_rgb()
  2. 6.2 image_captcha/image_captcha.user.inc \_image_captcha_hex_to_rgb()
  3. 6 image_captcha/image_captcha.user.inc \_image_captcha_hex_to_rgb()

Small helper function for parsing a hexadecimal color to a RGB tuple.

2 calls to _image_captcha_hex_to_rgb()
_image_captcha_generate_image in image_captcha/image_captcha.user.inc
Base function for generating a image CAPTCHA.
_image_captcha_image_generator_print_string in image_captcha/image_captcha.user.inc
Helper function for drawing text on the image.

File

image_captcha/image_captcha.user.inc, line 63
Functions for the generation of the CAPTCHA image.

Code

function _image_captcha_hex_to_rgb($hex) {

  // Handle #RGB format/
  if (strlen($hex) == 4) {
    $hex = $hex[1] . $hex[1] . $hex[2] . $hex[2] . $hex[3] . $hex[3];
  }
  $c = hexdec($hex);
  $rgb = array();
  for ($i = 16; $i >= 0; $i -= 8) {
    $rgb[] = $c >> $i & 0xff;
  }
  return $rgb;
}