CGIFIMAGE

The Gravity PDF CGIFIMAGE class.

Defined (1)

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

/vendor/blueliquiddesigns/mpdf/classes/gif.php  
  1. class CGIFIMAGE 
  2.  
  3. var $m_disp; 
  4.  
  5. var $m_bUser; 
  6.  
  7. var $m_bTrans; 
  8.  
  9. var $m_nDelay; 
  10.  
  11. var $m_nTrans; 
  12.  
  13. var $m_lpComm; 
  14.  
  15. var $m_gih; 
  16.  
  17. var $m_data; 
  18.  
  19. var $m_lzw; 
  20.  
  21. public function __construct() 
  22. unSet($this->m_disp); 
  23. unSet($this->m_bUser); 
  24. unSet($this->m_bTrans); 
  25. unSet($this->m_nDelay); 
  26. unSet($this->m_nTrans); 
  27. unSet($this->m_lpComm); 
  28. unSet($this->m_data); 
  29. $this->m_gih = new CGIFIMAGEHEADER(); 
  30. $this->m_lzw = new CGIFLZW(); 
  31.  
  32. function load($data, &$datLen) 
  33. $datLen = 0; 
  34.  
  35. while (true) { 
  36. $b = ord($data[0]); 
  37. $data = substr($data, 1); 
  38. $datLen++; 
  39.  
  40. switch ($b) { 
  41. case 0x21: // Extension 
  42. $len = 0; 
  43. if (!$this->skipExt($data, $len)) { 
  44. return false; 
  45. $datLen += $len; 
  46. break; 
  47.  
  48. case 0x2C: // Image 
  49. // LOAD HEADER & COLOR TABLE 
  50. $len = 0; 
  51. if (!$this->m_gih->load($data, $len)) { 
  52. return false; 
  53. $data = substr($data, $len); 
  54. $datLen += $len; 
  55.  
  56. // ALLOC BUFFER 
  57. $len = 0; 
  58.  
  59. if (!($this->m_data = $this->m_lzw->deCompress($data, $len))) { 
  60. return false; 
  61.  
  62. $data = substr($data, $len); 
  63. $datLen += $len; 
  64.  
  65. if ($this->m_gih->m_bInterlace) { 
  66. $this->deInterlace(); 
  67.  
  68. return true; 
  69.  
  70. case 0x3B: // EOF 
  71. default: 
  72. return false; 
  73. return false; 
  74.  
  75. function skipExt(&$data, &$extLen) 
  76. $extLen = 0; 
  77.  
  78. $b = ord($data[0]); 
  79. $data = substr($data, 1); 
  80. $extLen++; 
  81.  
  82. switch ($b) { 
  83. case 0xF9: // Graphic Control 
  84. $b = ord($data[1]); 
  85. $this->m_disp = ($b & 0x1C) >> 2; 
  86. $this->m_bUser = ($b & 0x02) ? true : false; 
  87. $this->m_bTrans = ($b & 0x01) ? true : false; 
  88. $this->m_nDelay = $this->w2i(substr($data, 2, 2)); 
  89. $this->m_nTrans = ord($data[4]); 
  90. break; 
  91.  
  92. case 0xFE: // Comment 
  93. $this->m_lpComm = substr($data, 1, ord($data[0])); 
  94. break; 
  95.  
  96. case 0x01: // Plain text 
  97. break; 
  98.  
  99. case 0xFF: // Application 
  100. break; 
  101.  
  102. // SKIP DEFAULT AS DEFS MAY CHANGE 
  103. $b = ord($data[0]); 
  104. $data = substr($data, 1); 
  105. $extLen++; 
  106. while ($b > 0) { 
  107. $data = substr($data, $b); 
  108. $extLen += $b; 
  109. $b = ord($data[0]); 
  110. $data = substr($data, 1); 
  111. $extLen++; 
  112. return true; 
  113.  
  114. function w2i($str) 
  115. return ord(substr($str, 0, 1)) + (ord(substr($str, 1, 1)) << 8); 
  116.  
  117. function deInterlace() 
  118. $data = $this->m_data; 
  119.  
  120. for ($i = 0; $i < 4; $i++) { 
  121. switch ($i) { 
  122. case 0: 
  123. $s = 8; 
  124. $y = 0; 
  125. break; 
  126.  
  127. case 1: 
  128. $s = 8; 
  129. $y = 4; 
  130. break; 
  131.  
  132. case 2: 
  133. $s = 4; 
  134. $y = 2; 
  135. break; 
  136.  
  137. case 3: 
  138. $s = 2; 
  139. $y = 1; 
  140. break; 
  141.  
  142. for (; $y < $this->m_gih->m_nHeight; $y += $s) { 
  143. $lne = substr($this->m_data, 0, $this->m_gih->m_nWidth); 
  144. $this->m_data = substr($this->m_data, $this->m_gih->m_nWidth); 
  145.  
  146. $data = substr($data, 0, $y * $this->m_gih->m_nWidth) . 
  147. $lne . 
  148. substr($data, ($y + 1) * $this->m_gih->m_nWidth); 
  149.  
  150. $this->m_data = $data; 
  151.