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开发者_JAVA技巧 be a way?
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;
精彩评论