CGIFCOLORTABLE

The Gravity PDF CGIFCOLORTABLE class.

Defined (1)

The class is defined in the following location(s).

/vendor/blueliquiddesigns/mpdf/classes/gif.php  
  1. class CGIFCOLORTABLE 
  2.  
  3. var $m_nColors; 
  4.  
  5. var $m_arColors; 
  6.  
  7. public function __construct() 
  8. unSet($this->m_nColors); 
  9. unSet($this->m_arColors); 
  10.  
  11. function load($lpData, $num) 
  12. $this->m_nColors = 0; 
  13. $this->m_arColors = array(); 
  14.  
  15. for ($i = 0; $i < $num; $i++) { 
  16. $rgb = substr($lpData, $i * 3, 3); 
  17. if (strlen($rgb) < 3) { 
  18. return false; 
  19.  
  20. $this->m_arColors[] = (ord($rgb[2]) << 16) + (ord($rgb[1]) << 8) + ord($rgb[0]); 
  21. $this->m_nColors++; 
  22.  
  23. return true; 
  24.  
  25. function toString() 
  26. $ret = ""; 
  27.  
  28. for ($i = 0; $i < $this->m_nColors; $i++) { 
  29. $ret .= 
  30. chr(($this->m_arColors[$i] & 0x000000FF)) . // R 
  31. chr(($this->m_arColors[$i] & 0x0000FF00) >> 8) . // G 
  32. chr(($this->m_arColors[$i] & 0x00FF0000) >> 16); // B 
  33.  
  34. return $ret; 
  35.  
  36. function colorIndex($rgb) 
  37. $rgb = intval($rgb) & 0xFFFFFF; 
  38. $r1 = ($rgb & 0x0000FF); 
  39. $g1 = ($rgb & 0x00FF00) >> 8; 
  40. $b1 = ($rgb & 0xFF0000) >> 16; 
  41. $idx = -1; 
  42.  
  43. for ($i = 0; $i < $this->m_nColors; $i++) { 
  44. $r2 = ($this->m_arColors[$i] & 0x000000FF); 
  45. $g2 = ($this->m_arColors[$i] & 0x0000FF00) >> 8; 
  46. $b2 = ($this->m_arColors[$i] & 0x00FF0000) >> 16; 
  47. $d = abs($r2 - $r1) + abs($g2 - $g1) + abs($b2 - $b1); 
  48.  
  49. if (($idx == -1) || ($d < $dif)) { 
  50. $idx = $i; 
  51. $dif = $d; 
  52.  
  53. return $idx; 
  54.