supp_comp partial support (db/prefs management, usage is missing)
[brisk.git] / web / suprend.php
1 <?php
2 $comps = $_GET['comp'];
3 $c = array();
4
5 if (mb_strlen($comps, "ASCII") != 12)
6     exit;
7
8 for ($i = 0, $idx = 0 ; $i < 12 ; $i++) {
9     if (($comps[$i] >= '0' && $comps[$i] <= '9') ||
10         ($comps[$i] >= 'a' && $comps[$i] <= 'f')) {
11         if (($i % 2) == 1) {
12             $c[$idx] = hexdec(substr($comps, $i-1, 2));
13             $idx++;
14         }
15         continue;
16     }
17     exit;
18 }
19
20 header ('Content-type: image/png');
21 $img_r = @imagecreatefrompng("img/sup_msk_r.png");
22 $img_y = @imagecreatefrompng("img/sup_msk_y.png");
23
24 $ret = imagefilter($img_r, IMG_FILTER_COLORIZE, $c[0], $c[1], $c[2], 0);
25 $ret = imagefilter($img_y, IMG_FILTER_COLORIZE, $c[3], $c[4], $c[5], 0);
26
27 imagecopy($img_r, $img_y, 0,0, 0,0, 21, 16);
28
29 imagesavealpha($img_r, TRUE);
30
31 imagepng($img_r);
32 ?>