Login   Register  
PHP Classes
elePHPant
Icontem

BUG: Can't do 256 wide icons, PNG icons, big-endian machines

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Ico  >  All threads  >  BUG: Can't do 256 wide icons, PNG icons, big-endian machines  >  (Un) Subscribe thread alerts  
Subject:BUG: Can't do 256 wide icons, PNG icons, big-endian machines
Summary:Code given to add support for these
Messages:2
Author:Jeffrey Bush
Date:2008-10-07 00:29:02
Update:2011-12-23 19:43:19
 

  1. BUG: Can't do 256 wide icons, PNG icons, big-endian machines   Reply   Report abuse  
Picture of Jeffrey Bush
Jeffrey Bush
2008-10-07 00:29:02
There are a few problems that I have found how to correct.

1) On some machines the machine byte order is not the icon byte order. In all unpack statements, L should be V and S should be v to add support for these machines.

2) To support icons that are 256 pixels wide/tall, the following code needs to be added to the middle of the first loop of LoadData:
if ($icodata['Height'] == 0) $icodata['Height'] = 256;
if ($icodata['Width'] == 0) $icodata['Width'] = 256;

3) Some icons use embedded PNG files which this class does not support. To add support for this the following code needs to be added to the beginning of the second loop of LoadData:
if (substr($data, $this->formats[$i]['FileOffset'], 8) == "\x89PNG\x0D\x0A\x1A\x0A") {
$this->formats[$i]['isPNG'] = true;
$this->formats[$i]['data'] = substr($data, $this->formats[$i]['FileOffset'], $this->formats[$i]['SizeInBytes']);
$this->formats[$i]['data_length'] = $this->formats[$i]['SizeInBytes'];
continue;
}
$this->formats[$i]['isPNG'] = false;
And the following code needs to be added GetIcon after the first if statement:
if ($this->formats[$index]['isPNG']) {
if ($this->bgcolor_transparent)
return imagecreatefromstring($this->formats[$index]['data']);
$im = imagecreatetruecolor($this->formats[$index]['Width'], $this->formats[$index]['Height']);
$bgcolor = $this->AllocateColor($im, $this->bgcolor[0], $this->bgcolor[1], $this->bgcolor[2]);
imagefilledrectangle($im, 0 , 0, $this->formats[$index]['Width'], $this->formats[$index]['Height'], $bgcolor);
$png = imagecreatefromstring($this->formats[$index]['data']);
imagecopy($im, $png, 0, 0, 0, 0, $this->formats[$index]['Width'], $this->formats[$index]['Height']);
imagedestroy($png);
return $im;
}

  2. Re: BUG: Can't do 256 wide icons, PNG icons, big-endian machines   Reply   Report abuse  
Picture of sepp
sepp
2011-12-23 19:43:19 - In reply to message 1 from Jeffrey Bush
Thank you very much! :)