File: dmtx.php

package info (click to toggle)
libdmtx 0.7.2-2%2Bbuild1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 3,676 kB
  • sloc: sh: 10,371; ansic: 10,144; cs: 596; makefile: 204; java: 161; objc: 157; python: 125; perl: 28; php: 18; ruby: 16
file content (26 lines) | stat: -rw-r--r-- 550 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
	$dmtx = dmtx_write($_GET["d"]);

	$size = dmtx_getSize($dmtx);
	$gd = imagecreatetruecolor($size['width'], $size['height']);

	$bg = imagecolorallocate($gd, 255, 255, 255);
	$fg = imagecolorallocate($gd, 0, 0, 0);

	$line = 0;
	while (($row = dmtx_getRow($dmtx)) != null) {

		for ($x = count($row) - 1; $x >= 0; $x--) {
			if ($row[$x]['R'] == 0)
				imagesetpixel($gd, $x, $line, $fg);
			else
				imagesetpixel($gd, $x, $line, $bg);
		}
		$line++;
	}

	$output_image = $gd;

	header("Content-type: image/png");
	imagepng($output_image);
?>