@@ -123,16 +123,16 @@ discard block |
||
123 | 123 | $bitmapinfo = unpack("Vsize", $data); |
124 | 124 | if ($bitmapinfo["size"] == 40) { |
125 | 125 | $info = unpack("Vsize/" . |
126 | - "Vwidth/" . |
|
127 | - "Vheight/" . |
|
128 | - "vplanes/" . |
|
129 | - "vbpp/" . |
|
130 | - "Vcompress/" . |
|
131 | - "Vsize/" . |
|
132 | - "Vxres/" . |
|
133 | - "Vyres/" . |
|
134 | - "Vpalcolors/" . |
|
135 | - "Vimpcolors/", $data); |
|
126 | + "Vwidth/" . |
|
127 | + "Vheight/" . |
|
128 | + "vplanes/" . |
|
129 | + "vbpp/" . |
|
130 | + "Vcompress/" . |
|
131 | + "Vsize/" . |
|
132 | + "Vxres/" . |
|
133 | + "Vyres/" . |
|
134 | + "Vpalcolors/" . |
|
135 | + "Vimpcolors/", $data); |
|
136 | 136 | if ($e["bpp"] == 0) { |
137 | 137 | $e["bpp"] = $info["bpp"]; |
138 | 138 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | for ($y = 0; $y < $height; $y++) { |
240 | 240 | for ($x = 0; $x < $width; $x++) { |
241 | 241 | imagesetpixel($img, $x, $y, |
242 | - $XOR[$y][$x]); |
|
242 | + $XOR[$y][$x]); |
|
243 | 243 | } |
244 | 244 | } |
245 | 245 | return $img; |
@@ -250,10 +250,10 @@ discard block |
||
250 | 250 | $x = 0; |
251 | 251 | while ($x < $width) { |
252 | 252 | for ($b = 0x80; |
253 | - $b > 0 && $x < $width; $b >>= 1) { |
|
253 | + $b > 0 && $x < $width; $b >>= 1) { |
|
254 | 254 | if (!(ord($data[$offset]) & $b)) { |
255 | 255 | imagesetpixel($img, $x, $y, |
256 | - $XOR[$y][$x]); |
|
256 | + $XOR[$y][$x]); |
|
257 | 257 | } |
258 | 258 | $x++; |
259 | 259 | } |
@@ -21,146 +21,146 @@ |
||
21 | 21 | */ |
22 | 22 | |
23 | 23 | |
24 | - // Simple class to wrap file streams, string streams, etc. |
|
25 | - // seek is essential, and it should be byte stream |
|
24 | + // Simple class to wrap file streams, string streams, etc. |
|
25 | + // seek is essential, and it should be byte stream |
|
26 | 26 | class StreamReader { |
27 | - // should return a string [FIXME: perhaps return array of bytes?] |
|
28 | - function read($bytes) { |
|
27 | + // should return a string [FIXME: perhaps return array of bytes?] |
|
28 | + function read($bytes) { |
|
29 | 29 | return false; |
30 | - } |
|
30 | + } |
|
31 | 31 | |
32 | - // should return new position |
|
33 | - function seekto($position) { |
|
32 | + // should return new position |
|
33 | + function seekto($position) { |
|
34 | 34 | return false; |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | - // returns current position |
|
38 | - function currentpos() { |
|
37 | + // returns current position |
|
38 | + function currentpos() { |
|
39 | 39 | return false; |
40 | - } |
|
40 | + } |
|
41 | 41 | |
42 | - // returns length of entire stream (limit for seekto()s) |
|
43 | - function length() { |
|
42 | + // returns length of entire stream (limit for seekto()s) |
|
43 | + function length() { |
|
44 | 44 | return false; |
45 | - } |
|
45 | + } |
|
46 | 46 | }; |
47 | 47 | |
48 | 48 | class StringReader { |
49 | - var $_pos; |
|
50 | - var $_str; |
|
49 | + var $_pos; |
|
50 | + var $_str; |
|
51 | 51 | |
52 | - function StringReader($str='') { |
|
52 | + function StringReader($str='') { |
|
53 | 53 | $this->_str = $str; |
54 | 54 | $this->_pos = 0; |
55 | - } |
|
55 | + } |
|
56 | 56 | |
57 | - function read($bytes) { |
|
57 | + function read($bytes) { |
|
58 | 58 | $data = substr($this->_str, $this->_pos, $bytes); |
59 | 59 | $this->_pos += $bytes; |
60 | 60 | if (strlen($this->_str)<$this->_pos) |
61 | - $this->_pos = strlen($this->_str); |
|
61 | + $this->_pos = strlen($this->_str); |
|
62 | 62 | |
63 | 63 | return $data; |
64 | - } |
|
64 | + } |
|
65 | 65 | |
66 | - function seekto($pos) { |
|
66 | + function seekto($pos) { |
|
67 | 67 | $this->_pos = $pos; |
68 | 68 | if (strlen($this->_str)<$this->_pos) |
69 | - $this->_pos = strlen($this->_str); |
|
69 | + $this->_pos = strlen($this->_str); |
|
70 | 70 | return $this->_pos; |
71 | - } |
|
71 | + } |
|
72 | 72 | |
73 | - function currentpos() { |
|
73 | + function currentpos() { |
|
74 | 74 | return $this->_pos; |
75 | - } |
|
75 | + } |
|
76 | 76 | |
77 | - function length() { |
|
77 | + function length() { |
|
78 | 78 | return strlen($this->_str); |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | 81 | }; |
82 | 82 | |
83 | 83 | |
84 | 84 | class FileReader { |
85 | - var $_pos; |
|
86 | - var $_fd; |
|
87 | - var $_length; |
|
85 | + var $_pos; |
|
86 | + var $_fd; |
|
87 | + var $_length; |
|
88 | 88 | |
89 | - function FileReader($filename) { |
|
89 | + function FileReader($filename) { |
|
90 | 90 | if (file_exists($filename)) { |
91 | 91 | |
92 | - $this->_length=filesize($filename); |
|
93 | - $this->_pos = 0; |
|
94 | - $this->_fd = fopen($filename,'rb'); |
|
95 | - if (!$this->_fd) { |
|
92 | + $this->_length=filesize($filename); |
|
93 | + $this->_pos = 0; |
|
94 | + $this->_fd = fopen($filename,'rb'); |
|
95 | + if (!$this->_fd) { |
|
96 | 96 | $this->error = 3; // Cannot read file, probably permissions |
97 | 97 | return false; |
98 | - } |
|
98 | + } |
|
99 | 99 | } else { |
100 | - $this->error = 2; // File doesn't exist |
|
101 | - return false; |
|
100 | + $this->error = 2; // File doesn't exist |
|
101 | + return false; |
|
102 | + } |
|
102 | 103 | } |
103 | - } |
|
104 | 104 | |
105 | - function read($bytes) { |
|
105 | + function read($bytes) { |
|
106 | 106 | if ($bytes) { |
107 | - fseek($this->_fd, $this->_pos); |
|
107 | + fseek($this->_fd, $this->_pos); |
|
108 | 108 | |
109 | - // PHP 5.1.1 does not read more than 8192 bytes in one fread() |
|
110 | - // the discussions at PHP Bugs suggest it's the intended behaviour |
|
111 | - $data = ''; |
|
112 | - while ($bytes > 0) { |
|
109 | + // PHP 5.1.1 does not read more than 8192 bytes in one fread() |
|
110 | + // the discussions at PHP Bugs suggest it's the intended behaviour |
|
111 | + $data = ''; |
|
112 | + while ($bytes > 0) { |
|
113 | 113 | $chunk = fread($this->_fd, $bytes); |
114 | 114 | $data .= $chunk; |
115 | 115 | $bytes -= strlen($chunk); |
116 | - } |
|
117 | - $this->_pos = ftell($this->_fd); |
|
116 | + } |
|
117 | + $this->_pos = ftell($this->_fd); |
|
118 | 118 | |
119 | - return $data; |
|
119 | + return $data; |
|
120 | 120 | } else return ''; |
121 | - } |
|
121 | + } |
|
122 | 122 | |
123 | - function seekto($pos) { |
|
123 | + function seekto($pos) { |
|
124 | 124 | fseek($this->_fd, $pos); |
125 | 125 | $this->_pos = ftell($this->_fd); |
126 | 126 | return $this->_pos; |
127 | - } |
|
127 | + } |
|
128 | 128 | |
129 | - function currentpos() { |
|
129 | + function currentpos() { |
|
130 | 130 | return $this->_pos; |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | - function length() { |
|
133 | + function length() { |
|
134 | 134 | return $this->_length; |
135 | - } |
|
135 | + } |
|
136 | 136 | |
137 | - function close() { |
|
137 | + function close() { |
|
138 | 138 | fclose($this->_fd); |
139 | - } |
|
139 | + } |
|
140 | 140 | |
141 | 141 | }; |
142 | 142 | |
143 | 143 | // Preloads entire file in memory first, then creates a StringReader |
144 | 144 | // over it (it assumes knowledge of StringReader internals) |
145 | 145 | class CachedFileReader extends StringReader { |
146 | - function CachedFileReader($filename) { |
|
146 | + function CachedFileReader($filename) { |
|
147 | 147 | if (file_exists($filename)) { |
148 | 148 | |
149 | - $length=filesize($filename); |
|
150 | - $fd = fopen($filename,'rb'); |
|
149 | + $length=filesize($filename); |
|
150 | + $fd = fopen($filename,'rb'); |
|
151 | 151 | |
152 | - if (!$fd) { |
|
152 | + if (!$fd) { |
|
153 | 153 | $this->error = 3; // Cannot read file, probably permissions |
154 | 154 | return false; |
155 | - } |
|
156 | - $this->_str = fread($fd, $length); |
|
157 | - fclose($fd); |
|
155 | + } |
|
156 | + $this->_str = fread($fd, $length); |
|
157 | + fclose($fd); |
|
158 | 158 | |
159 | 159 | } else { |
160 | - $this->error = 2; // File doesn't exist |
|
161 | - return false; |
|
160 | + $this->error = 2; // File doesn't exist |
|
161 | + return false; |
|
162 | + } |
|
162 | 163 | } |
163 | - } |
|
164 | 164 | }; |
165 | 165 | |
166 | 166 |
@@ -422,7 +422,7 @@ |
||
422 | 422 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
423 | 423 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
424 | 424 | 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, |
425 | - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, |
|
425 | + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, |
|
426 | 426 | -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
427 | 427 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, |
428 | 428 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | //---------------------------------------------------------------------- |
79 | 79 | public static function buildCache() |
80 | 80 | { |
81 | - QRtools::markTime('before_build_cache'); |
|
81 | + QRtools::markTime('before_build_cache'); |
|
82 | 82 | |
83 | - $mask = new QRmask(); |
|
83 | + $mask = new QRmask(); |
|
84 | 84 | for ($a=1; $a <= QRSPEC_VERSION_MAX; $a++) { |
85 | 85 | $frame = QRspec::newFrame($a); |
86 | 86 | if (QR_IMAGE) { |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | QRimage::png(self::binarize($frame), $fileName, 1, 0); |
89 | 89 | } |
90 | 90 | |
91 | - $width = count($frame); |
|
92 | - $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
|
93 | - for ($maskNo=0; $maskNo<8; $maskNo++) |
|
94 | - $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
91 | + $width = count($frame); |
|
92 | + $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
|
93 | + for ($maskNo=0; $maskNo<8; $maskNo++) |
|
94 | + $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
95 | 95 | } |
96 | 96 | |
97 | - QRtools::markTime('after_build_cache'); |
|
97 | + QRtools::markTime('after_build_cache'); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | //---------------------------------------------------------------------- |
@@ -25,19 +25,19 @@ |
||
25 | 25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
26 | 26 | */ |
27 | 27 | |
28 | - $QR_BASEDIR = dirname(__FILE__).DIRECTORY_SEPARATOR; |
|
28 | + $QR_BASEDIR = dirname(__FILE__).DIRECTORY_SEPARATOR; |
|
29 | 29 | |
30 | - // Required libs |
|
30 | + // Required libs |
|
31 | 31 | |
32 | - include $QR_BASEDIR."qrconst.php"; |
|
33 | - include $QR_BASEDIR."qrconfig.php"; |
|
34 | - include $QR_BASEDIR."qrtools.php"; |
|
35 | - include $QR_BASEDIR."qrspec.php"; |
|
36 | - include $QR_BASEDIR."qrimage.php"; |
|
37 | - include $QR_BASEDIR."qrinput.php"; |
|
38 | - include $QR_BASEDIR."qrbitstream.php"; |
|
39 | - include $QR_BASEDIR."qrsplit.php"; |
|
40 | - include $QR_BASEDIR."qrrscode.php"; |
|
41 | - include $QR_BASEDIR."qrmask.php"; |
|
42 | - include $QR_BASEDIR."qrencode.php"; |
|
32 | + include $QR_BASEDIR."qrconst.php"; |
|
33 | + include $QR_BASEDIR."qrconfig.php"; |
|
34 | + include $QR_BASEDIR."qrtools.php"; |
|
35 | + include $QR_BASEDIR."qrspec.php"; |
|
36 | + include $QR_BASEDIR."qrimage.php"; |
|
37 | + include $QR_BASEDIR."qrinput.php"; |
|
38 | + include $QR_BASEDIR."qrbitstream.php"; |
|
39 | + include $QR_BASEDIR."qrsplit.php"; |
|
40 | + include $QR_BASEDIR."qrrscode.php"; |
|
41 | + include $QR_BASEDIR."qrmask.php"; |
|
42 | + include $QR_BASEDIR."qrencode.php"; |
|
43 | 43 |
@@ -59,7 +59,7 @@ |
||
59 | 59 | $outputCode .= "\n\n".$anotherCode."\n\n"; |
60 | 60 | } |
61 | 61 | |
62 | - $versionDataEx = explode("\n", file_get_contents($versionFile)); |
|
62 | + $versionDataEx = explode("\n", file_get_contents($versionFile)); |
|
63 | 63 | |
64 | 64 | $outputContents = file_get_contents($headerFile); |
65 | 65 | $outputContents .= "\n\n/*\n * Version: ".trim($versionDataEx[0])."\n * Build: ".trim($versionDataEx[1])."\n */\n\n"; |
@@ -33,4 +33,4 @@ |
||
33 | 33 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
34 | 34 | */ |
35 | 35 | |
36 | - |
|
37 | 36 | \ No newline at end of file |
37 | + |
|
38 | 38 | \ No newline at end of file |
@@ -14,4 +14,4 @@ |
||
14 | 14 | define('QR_DEFAULT_MASK', 2); // when QR_FIND_BEST_MASK === false |
15 | 15 | |
16 | 16 | define('QR_PNG_MAXIMUM_SIZE', 1024); // maximum allowed png image width (in pixels), tune to make sure GD and PHP can handle such big images |
17 | - |
|
18 | 17 | \ No newline at end of file |
18 | + |
|
19 | 19 | \ No newline at end of file |
@@ -74,32 +74,32 @@ discard block |
||
74 | 74 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
75 | 75 | */ |
76 | 76 | |
77 | - // Encoding modes |
|
77 | + // Encoding modes |
|
78 | 78 | |
79 | - define('QR_MODE_NUL', -1); |
|
80 | - define('QR_MODE_NUM', 0); |
|
81 | - define('QR_MODE_AN', 1); |
|
82 | - define('QR_MODE_8', 2); |
|
83 | - define('QR_MODE_KANJI', 3); |
|
84 | - define('QR_MODE_STRUCTURE', 4); |
|
85 | - |
|
86 | - // Levels of error correction. |
|
87 | - |
|
88 | - define('QR_ECLEVEL_L', 0); |
|
89 | - define('QR_ECLEVEL_M', 1); |
|
90 | - define('QR_ECLEVEL_Q', 2); |
|
91 | - define('QR_ECLEVEL_H', 3); |
|
79 | + define('QR_MODE_NUL', -1); |
|
80 | + define('QR_MODE_NUM', 0); |
|
81 | + define('QR_MODE_AN', 1); |
|
82 | + define('QR_MODE_8', 2); |
|
83 | + define('QR_MODE_KANJI', 3); |
|
84 | + define('QR_MODE_STRUCTURE', 4); |
|
85 | + |
|
86 | + // Levels of error correction. |
|
87 | + |
|
88 | + define('QR_ECLEVEL_L', 0); |
|
89 | + define('QR_ECLEVEL_M', 1); |
|
90 | + define('QR_ECLEVEL_Q', 2); |
|
91 | + define('QR_ECLEVEL_H', 3); |
|
92 | 92 | |
93 | - // Supported output formats |
|
93 | + // Supported output formats |
|
94 | 94 | |
95 | - define('QR_FORMAT_TEXT', 0); |
|
96 | - define('QR_FORMAT_PNG', 1); |
|
95 | + define('QR_FORMAT_TEXT', 0); |
|
96 | + define('QR_FORMAT_PNG', 1); |
|
97 | 97 | |
98 | - class qrstr { |
|
99 | - public static function set(&$srctab, $x, $y, $repl, $replLen = false) { |
|
100 | - $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl)); |
|
101 | - } |
|
102 | - } |
|
98 | + class qrstr { |
|
99 | + public static function set(&$srctab, $x, $y, $repl, $replLen = false) { |
|
100 | + $srctab[$y] = substr_replace($srctab[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl)); |
|
101 | + } |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | 105 | |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | //---------------------------------------------------------------------- |
212 | 212 | public static function buildCache() |
213 | 213 | { |
214 | - QRtools::markTime('before_build_cache'); |
|
214 | + QRtools::markTime('before_build_cache'); |
|
215 | 215 | |
216 | - $mask = new QRmask(); |
|
216 | + $mask = new QRmask(); |
|
217 | 217 | for ($a=1; $a <= QRSPEC_VERSION_MAX; $a++) { |
218 | 218 | $frame = QRspec::newFrame($a); |
219 | 219 | if (QR_IMAGE) { |
@@ -221,13 +221,13 @@ discard block |
||
221 | 221 | QRimage::png(self::binarize($frame), $fileName, 1, 0); |
222 | 222 | } |
223 | 223 | |
224 | - $width = count($frame); |
|
225 | - $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
|
226 | - for ($maskNo=0; $maskNo<8; $maskNo++) |
|
227 | - $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
224 | + $width = count($frame); |
|
225 | + $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); |
|
226 | + for ($maskNo=0; $maskNo<8; $maskNo++) |
|
227 | + $mask->makeMaskNo($maskNo, $width, $frame, $bitMask, true); |
|
228 | 228 | } |
229 | 229 | |
230 | - QRtools::markTime('after_build_cache'); |
|
230 | + QRtools::markTime('after_build_cache'); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | //---------------------------------------------------------------------- |
@@ -647,10 +647,10 @@ discard block |
||
647 | 647 | |
648 | 648 | // Version information pattern ----------------------------------------- |
649 | 649 | |
650 | - // Version information pattern (BCH coded). |
|
650 | + // Version information pattern (BCH coded). |
|
651 | 651 | // See Table 1 in Appendix D (pp.68) of JIS X0510:2004. |
652 | 652 | |
653 | - // size: [QRSPEC_VERSION_MAX - 6] |
|
653 | + // size: [QRSPEC_VERSION_MAX - 6] |
|
654 | 654 | |
655 | 655 | public static $versionPattern = array( |
656 | 656 | 0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, |
@@ -1435,7 +1435,7 @@ discard block |
||
1435 | 1435 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
1436 | 1436 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
1437 | 1437 | 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, |
1438 | - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, |
|
1438 | + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, |
|
1439 | 1439 | -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, |
1440 | 1440 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, |
1441 | 1441 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
@@ -2497,17 +2497,17 @@ discard block |
||
2497 | 2497 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
2498 | 2498 | */ |
2499 | 2499 | |
2500 | - define('N1', 3); |
|
2501 | - define('N2', 3); |
|
2502 | - define('N3', 40); |
|
2503 | - define('N4', 10); |
|
2500 | + define('N1', 3); |
|
2501 | + define('N2', 3); |
|
2502 | + define('N3', 40); |
|
2503 | + define('N4', 10); |
|
2504 | 2504 | |
2505 | - class QRmask { |
|
2505 | + class QRmask { |
|
2506 | 2506 | |
2507 | - public $runLength = array(); |
|
2507 | + public $runLength = array(); |
|
2508 | 2508 | |
2509 | - //---------------------------------------------------------------------- |
|
2510 | - public function __construct() |
|
2509 | + //---------------------------------------------------------------------- |
|
2510 | + public function __construct() |
|
2511 | 2511 | { |
2512 | 2512 | $this->runLength = array_fill(0, QRSPEC_WIDTH_MAX + 1, 0); |
2513 | 2513 | } |