tags:

views:

17

answers:

1

After working with a lot of GD recently (for some fairly large scale projects for work) I had been dealing with RGB codes that I am not so accustomed to.

My co-workers and I had been suffering some what to find a good method to do this without resorting to a makeshift 'hex to rgb' function with arrays for just a simple function.

There must be a way?

+1  A: 

If I am aware imagecolorallocate() only returns a hex representation to be used by the other GD functions, as the library is a bit lower level than PHP of course it works with hex values directly, so there raised a need for an intermediate function to assign a colour.

The following should be equivalent:

$im = imagecreatetruecolor("200", "100");
$white = imagecolorallocate($im, 255, 255, 255);
$white = 0x00FFFFFF;
$alphagreen = imagecolorallocatealpha($im, 0, 255, 0, 64); 
$alphagreen = 0x4000FF00;
Nullw0rm
@Nullw0rm: So the format is simply AARRGGBB?
John
@John: Yes, exactly.
Nullw0rm
Although just note you will be required the `true color` format to use this.
Nullw0rm
Thanks alot then.
John