Login   Register  
PHP Classes
elePHPant
Icontem

4 bits icons count bug

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

      Ico  >  All threads  >  4 bits icons count bug  >  (Un) Subscribe thread alerts  
Subject:4 bits icons count bug
Summary:There is a bug regarding the 4 bits icons + FIX
Messages:2
Author:Dzsoni Voker
Date:2009-09-01 00:01:08
Update:2009-09-01 12:17:07
 

  1. 4 bits icons count bug   Reply  
Picture of Dzsoni Voker
Dzsoni Voker
2009-09-01 00:01:08
Hello!

The script doesn't manage the 4 bits icons correctly.

My version of the bug fix:

Change lines 361-364 form:

$color = array(
'High' => bindec(substr(decbin(ord($color)), 0, 4)),
'Low' => bindec(substr(decbin(ord($color)), 4))
);

To:

$color = array(
'High' => ord($color) >> 4,
'Low' => ord($color) & 0x0F
);

  2. Re: 4 bits icons count bug   Reply  
Picture of Dzsoni Voker
Dzsoni Voker
2009-09-01 12:17:08 - In reply to message 1 from Dzsoni Voker
Or here is another way to fix this bug, using string functions like the original script:

$color = array(
'High' => bindec(substr(str_pad(decbin(ord($t_c)), 8, "0", STR_PAD_LEFT), 0, 4)),
'Low' => bindec(substr(str_pad(decbin(ord($t_c)), 8, "0", STR_PAD_LEFT), 4))
);

But I think the use of bitwise operators is quicker than calling 5 different functions to get the nibble value.