Dysan Posted January 13, 2008 Share Posted January 13, 2008 It's been a long time since the basis of this script was written, and therefore I can't remember how the values in the array ($replace) are generated. Can anybody jog my memory? <?php $rectangle_width = 2; $rectangle_height = 100; $image = imagecreatetruecolor(300, 188); $white = imagecolorallocate($image, 255, 255, 255); $black = imagecolorallocate($image, 0, 0, 0); imagefill($image, 0, 0, $white); imagerectangle($image, 0, 0, 298, 186, $black); $find = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*'); $replace = array('1010001110111010', '1110100010101110', '1011100010101110', '1110111000101010', '1010001110101110', '1110100011101010', '1011100011101010', '1010001011101110', '1110100010111010', '1011100010111010', '1000101110111010'); $string = '*111111*'; $textstring = str_replace($find, $replace, $string); $j = 11; $sarray = str_split($textstring, 1); for($i = 0; $i < count($sarray); $i++) { if($sarray[$i] == '0') { imagefilledrectangle($image, $rectangle_width * $j, 150, ($rectangle_width * $j) + $rectangle_width, $rectangle_height, $white); $j++; } elseif($sarray[$i] == '1') { imagefilledrectangle($image, $rectangle_width * $j, 150, ($rectangle_width * $j) + $rectangle_width, $rectangle_height, $black); $j++; } } imagettftext($image, 10, 0, 120, 170, $black, "Verdana", $string); header("Content-type: image/jpeg"); imagejpeg($image); imagedestroy($image); ?> Quote Link to comment https://forums.phpfreaks.com/topic/85846-jog-my-memory/ Share on other sites More sharing options...
niwa3836 Posted January 13, 2008 Share Posted January 13, 2008 Hi, when you say generated, do you mean how were they invented? Dont know the answer but its some clever sole who do it. Doesnt look like Code39 though? case ' ': return "011000100"; case '$': return "010101000"; case '%': return "000101010"; case '*': return "010010100"; // * Start/Stop case '+': return "010001010"; case '|': return "010000101"; case '.': return "110000100"; case '/': return "010100010"; case '-': return "010000101"; case '0': return "000110100"; case '1': return "100100001"; case '2': return "001100001"; case '3': return "101100000"; case '4': return "000110001"; case '5': return "100110000"; case '6': return "001110000"; case '7': return "000100101"; case '8': return "100100100"; case '9': return "001100100"; case 'A': return "100001001"; case 'B': return "001001001"; case 'C': return "101001000"; case 'D': return "000011001"; case 'E': return "100011000"; case 'F': return "001011000"; case 'G': return "000001101"; case 'H': return "100001100"; case 'I': return "001001100"; case 'J': return "000011100"; case 'K': return "100000011"; case 'L': return "001000011"; case 'M': return "101000010"; case 'N': return "000010011"; case 'O': return "100010010"; case 'P': return "001010010"; case 'Q': return "000000111"; case 'R': return "100000110"; case 'S': return "001000110"; case 'T': return "000010110"; case 'U': return "110000001"; case 'V': return "011000001"; case 'W': return "111000000"; case 'X': return "010010001"; case 'Y': return "110010000"; case 'Z': return "011010000"; default: return "011000100"; What coding is yours? On a seperate note, I am doing something similar with code39 (I have posted today question on printer_ functions). I am looking to get the output sent to the printer, but struggling with GD / Image components as printer_ wants BMP and GD doesnt appear to do it. Still I am a thicky Quote Link to comment https://forums.phpfreaks.com/topic/85846-jog-my-memory/#findComment-438168 Share on other sites More sharing options...
Dysan Posted January 13, 2008 Author Share Posted January 13, 2008 What coding is yours? What do you mean by this? Did you get that case statement from here?: http://www.sid6581.net/cs/php-scripts/barcode/ Quote Link to comment https://forums.phpfreaks.com/topic/85846-jog-my-memory/#findComment-438200 Share on other sites More sharing options...
Dysan Posted January 13, 2008 Author Share Posted January 13, 2008 I have just found out that they are not binary values, they are a string. According to the page found at the following URL, each character has 6 narrow and 3 wide bars plus an ending delimiter. http://www.barcodeman.com/info/c39_1.php3 There is a 3:1 ratio for wide bars meaning the 3 wide bars take the space of 9 narrow ones. So 3 wide (equiv. 9 narrow) plus 6 narrow + delimiter = 16. Can a script be created that automatically generates the string automatically, allowing me to simply copy and paste the code into my barcode script? Quote Link to comment https://forums.phpfreaks.com/topic/85846-jog-my-memory/#findComment-438220 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.