Skip to content
This repository has been archived by the owner on Jan 6, 2020. It is now read-only.

Commit

Permalink
correct floIcon to work on big-endian architectures
Browse files Browse the repository at this point in the history
all unpacks where machine byte order dependant (by the use of S and L pack
codes)
using respectively v and V seems to correct the issue.

should fix fossar#255, fossar#294
  • Loading branch information
CircleCode committed Apr 29, 2013
1 parent 18166f1 commit 7f6f1d7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libs/floIcon.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ function getBestImage($height = 32, $width = 32) {
function readICO($file, $offset = 0) {
if (file_exists($file) && filesize($file) > 0 && $filePointer = fopen($file, "r")) {
fseek($filePointer, $offset);
$header = unpack("SReserved/SType/SCount", fread($filePointer, 6));
$header = unpack("vReserved/vType/vCount", fread($filePointer, 6));
for ($t = 0; $t < $header["Count"]; $t++) {
$newImage = new floIconImage();
$newImage->readImageFromICO($filePointer, 6 + ($t * 16));
Expand Down Expand Up @@ -778,14 +778,14 @@ function readImageFromICO($filePointer, $entryOffset) {
// Get the entry.
fseek($filePointer, $entryOffset);
$this->_entryIconFormat = fread($filePointer, 16);
$this->_entry = unpack("CWidth/CHeight/CColorCount/CReserved/SPlanes/SBitCount/LSizeInBytes/LFileOffset", $this->_entryIconFormat);
$this->_entry = unpack("CWidth/CHeight/CColorCount/CReserved/vPlanes/vBitCount/VSizeInBytes/VFileOffset", $this->_entryIconFormat);

// Position the file pointer.
fseek($filePointer, $this->_entry["FileOffset"]);

// Get the header.
$this->_headerIconFormat = fread($filePointer, 40);
$this->_header = unpack("LSize/LWidth/LHeight/SPlanes/SBitCount/LCompression/LImageSize/LXpixelsPerM/LYpixelsPerM/LColorsUsed/LColorsImportant", $this->_headerIconFormat);
$this->_header = unpack("VSize/VWidth/VHeight/vPlanes/vBitCount/VCompression/VImageSize/VXpixelsPerM/VYpixelsPerM/VColorsUsed/VColorsImportant", $this->_headerIconFormat);

// Get the image.
$this->_imageIconFormat = @fread($filePointer, $this->_entry["SizeInBytes"] - strlen($this->_headerIconFormat));
Expand Down

0 comments on commit 7f6f1d7

Please sign in to comment.