"10001",2=>"01001",3=>"11000",4=>"00101", 5=>"10100",6=>"01100",7=>"00011",8=" />
麻辣堂|资源主站|开发论坛|在线手册
首页 Apache Linux Java MySQL 注册帮助 
PHP项目开发组是PHP开发资源网于2007组年建成立的项目开发团队,目前核心开发成员有27人, 项目协作成员8名.下设7个开发组,主要承接大/中型网站项目开发任务。

    由于开发任务较多,人员比较紧张,现面向社会招聘全职或者兼职开发人员,不管你是在校大学生,还是全职开发人员,以及SOHO都可以联系本站,我们可以长期合作,并为您带来丰厚的报酬。
  您现在的位置:PHP开发资源网 > 麻辣堂 > 详细资料
待解决
一個生成條形碼的類
悬赏分:20 - 2007年08月21日

[php]
<?php
class cd_barra
{
var $file;
var $into;

var $cd_barras = array(0=>"00110",1=>"10001",2=>"01001",3=>"11000",4=>"00101",
5=>"10100",6=>"01100",7=>"00011",8=>"10010",9=>"01010"
);
function cd_barra($value,$into=1) {
$lower = 1 ; $hight = 50;
$this->into = $into;
for($count1=9;$count1>=0;$count1--){
for($count2=9;$count2>=0;$count2--){
$count = ($count1 * 10) + $count2 ;
$text = "" ;
for($i=1;$i<6;$i++){
$text .= substr($this->cd_barras[$count1],($i-1),1) . substr($this->cd_barras[$count2],($i-1),1);
}
$this->cd_barras[$count] = $text;
}
}

//$img = imagecreate($lower*95+300,$hight+30);
$img = imagecreate(395,73);
$cl_black = imagecolorallocate($img, 0, 0, 0);
$cl_white = imagecolorallocate($img, 255, 255, 255);



imagefilledrectangle($img, 0, 0, $lower*95+1000, $hight+30, $cl_white);


imagefilledrectangle($img, 1,5,1,65,$cl_black);
imagefilledrectangle($img, 2,5,2,65,$cl_white);
imagefilledrectangle($img, 3,5,3,65,$cl_black);
imagefilledrectangle($img, 4,5,4,65,$cl_white);



$thin = 1 ;
if(substr_count(strtoupper($_SERVER['SERVER_SOFTWARE']),"WIN32")){
//O tamanho para windows tem que ser 3
// For windows, the wide bar has = 3
$wide = 3;
} else {
$wide = 2.72;
}
$pos = 5 ;
$text = $value ;
if((strlen($text) % 2) <> 0){
$text = "0" . $text;
}


while (strlen($text) > 0) {
$i = round($this->barra_left($text,2));
$text = $this->barra_right($text,strlen($text)-2);

$f = $this->cd_barras[$i];

for($i=1;$i<11;$i+=2){
if (substr($f,($i-1),1) == "0") {
$f1 = $thin ;
}else{
$f1 = $wide ;
}


imagefilledrectangle($img, $pos,5,$pos-1+$f1,65,$cl_black) ;
$pos = $pos + $f1 ;

if (substr($f,$i,1) == "0") {
$f2 = $thin ;
}else{
$f2 = $wide ;
}

imagefilledrectangle($img, $pos,5,$pos-1+$f2,65,$cl_white) ;
$pos = $pos + $f2 ;
}
}


imagefilledrectangle($img, $pos,5,$pos-1+$wide,65,$cl_black);
$pos=$pos+$wide;

imagefilledrectangle($img, $pos,5,$pos-1+$thin,65,$cl_white);
$pos=$pos+$thin;


imagefilledrectangle($img, $pos,5,$pos-1+$thin,65,$cl_black);
$pos=$pos+$thin;

$this->put_img($img);
}

function barra_left($input,$comp){
return substr($input,0,$comp);
}

function barra_right($input,$comp){
return substr($input,strlen($input)-$comp,$comp);
}

function put_img($image,$file='test.gif'){
if($this->into){
imagegif($image,$this->file);
} else {
header("Content-type: image/gif");
imagegif($image);
}
imagedestroy($image);
}
}

?>
[/php]

提问者:meteor_shower   08-21 16:04
答复
路过。。。顺便帮顶:)
回答者:玉米づ冰冻可乐 - 瓦岗村民 8-22 09:10
我也来回答:
不管你有没有帮助我们,瓦岗寨8万村民将感谢你。。。。。

为防止灌水,您需要计算一道数学题: 答案:
50 + 37 = ? 请将计算结果填在上面

 
[]
©2007 PhpRes.COM