PHP allocate color without image resource

16711680 (decimal) is 0x00FF0000 (hexadecimal)

00 – Alpha value (0 dec)

FF – Red (255 dec)

00 – Green (0 dec)

00 – Blue (0 dec)

See http://www.php.net/manual/en/function.imagecolorallocatealpha.php to set the alpha byte

Edit:

Also, to answer your first question — yes, you can create a color without an image resource (and, consequently without a call to imagecolorallocate):

$col1 = 0x00FF0000; // Red

$col2 = 0x0000FF00; // Green

// etc…

Leave a Comment