| 936 | define('QR_IMAGE', true); |
| 937 | |
| 938 | class QRimage { |
| 939 | |
| 940 | //---------------------------------------------------------------------- |
| 941 | public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4,$saveandprint=FALSE) |
| 942 | { |
| 943 | $image = self::image($frame, $pixelPerPoint, $outerFrame); |
| 944 | |
| 945 | if ($filename === false) { |
| 946 | Header("Content-type: image/png"); |
| 947 | ImagePng($image); |
| 948 | } else { |
| 949 | if($saveandprint===TRUE){ |
| 950 | ImagePng($image, $filename); |
| 951 | header("Content-type: image/png"); |
| 952 | ImagePng($image); |
| 953 | }else{ |
| 954 | ImagePng($image, $filename); |
| 955 | } |
| 956 | } |
| 957 | |
| 958 | ImageDestroy($image); |
| 959 | } |
| 960 | |
| 961 | //---------------------------------------------------------------------- |
| 962 | public static function jpg($frame, $filename = false, $pixelPerPoint = 8, $outerFrame = 4, $q = 85) |
| 963 | { |
| 964 | $image = self::image($frame, $pixelPerPoint, $outerFrame); |
| 965 | |
| 966 | if ($filename === false) { |
| 967 | Header("Content-type: image/jpeg"); |
| 968 | ImageJpeg($image, null, $q); |
| 969 | } else { |
| 970 | ImageJpeg($image, $filename, $q); |
| 971 | } |
| 972 | |
| 973 | ImageDestroy($image); |
| 974 | } |
| 975 | |
| 976 | //---------------------------------------------------------------------- |
| 977 | private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4) |
| 978 | { |
| 979 | $h = count($frame); |
| 980 | $w = strlen($frame[0]); |
| 981 | |
| 982 | $imgW = $w + 2*$outerFrame; |
| 983 | $imgH = $h + 2*$outerFrame; |
| 984 | |
| 985 | $base_image =ImageCreate($imgW, $imgH); |
| 986 | |
| 987 | $col[0] = ImageColorAllocate($base_image,255,255,255); |
| 988 | $col[1] = ImageColorAllocate($base_image,0,0,0); |
| 989 | |
| 990 | imagefill($base_image, 0, 0, $col[0]); |
| 991 | |
| 992 | for($y=0; $y<$h; $y++) { |
| 993 | for($x=0; $x<$w; $x++) { |
| 994 | if ($frame[$y][$x] == '1') { |
| 995 | ImageSetPixel($base_image,$x+$outerFrame,$y+$outerFrame,$col[1]); |
nothing calls this directly
no outgoing calls
no test coverage detected