A few posts ago I wrote about using a PHP class to convert an ICO image to a PNG (or GIF or JPG). I just discovered a bug in the class.
I ran into a problem where some red and orange ICO images turned blue during the conversion. Reading this forum post made me realize that the red and blue values were switched somewhere in class.ico.php. With some experimentation I found it:
In class.ico.php, lines 264-267 need to be changed from
$c[$i] = $this->AllocateColor($im, $this->formats[$index]['colors'][$i]['red'],
$this->formats[$index]['colors'][$i]['green'],
$this->formats[$index]['colors'][$i]['blue'],
round($this->formats[$index]['colors'][$i]['reserved'] / 255 * 127));
to
$c[$i] = $this->AllocateColor($im, $this->formats[$index]['colors'][$i]['blue'],
$this->formats[$index]['colors'][$i]['green'],
$this->formats[$index]['colors'][$i]['red'],
round($this->formats[$index]['colors'][$i]['reserved'] / 255 * 127));
(Note that the blue and red values are indeed switched.) After changing this, it works like a charm for me.


