You are here: Re: newbie question - variable data types? « PHP Language « IT news, forums, messages
Re: newbie question - variable data types?

Posted by Michael Fesser on 09/04/07 11:21

..oO(Nerd Monster)

>Thanks Norm! Here's the problem, and you can test these complete examples on
>your own machine to verify.
>The following works correctly:

But it is not correct!

>-----
><?php
>$im = imagecreatetruecolor(100, 100);
>
>$fillcolor = imagecolorallocate($im, 0, 0, 0x00FF00);

As said, the numbers passed to imagecolorallocate() have to be 0..255.

To split a given hex string into its color parts, you could use string
functions or something like this:

function imageColorAllocateHex($im, $color) {
$c = hexdec($color);
return imageColorAllocate($im,
0xFF & $c >> 0x10,
0xFF & $c >> 0x8,
0xFF & $c
);
}

Usage:

$color = imageColorAllocateHex($im, '00FF00');

Micha

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация