setScale(5);// 分辨率(大小) $code->setThickness(65);// 高度 $code->setForegroundColor($colorFront); $code->setBackgroundColor($colorBack); $code->setFont($font); $code->parse($text); $time = date('Ymd',time()); $dir = "./data/img/number/".$time."/"; if(!is_dir($dir))mkdir($dir,0777); //上传目录不存在则创建 /* 绘制对象 */ $drawing = new BCGDrawing($dir.$text.".png", $colorFront); $drawing->setBarCode($code); $drawing->draw(); /* 作为文件下载 */ //header("Content-Type: image/png;"); //header("Content-Disposition:attachment;filename='barcode.png'"); $drawing->finish(BCGDrawing::IMG_FORMAT_PNG); return "/data/img/number/".$time."/".$text.".png"; } public function get_data2($text) { /* 颜色和字体 */ $colorFront = new BCGColor(0,0,0); $colorBack = new BCGColor(255,255,255); $font = new BCGFontFile("./data/barcode/font/Arial.ttf", 0); /* 编码对象 */ $code = new BCGcode128();//实例化对应的编码格式 $code->setScale(10);// 分辨率(大小) $code->setThickness(65);// 高度 $code->setForegroundColor($colorFront); $code->setBackgroundColor($colorBack); $code->setFont($font); $code->parse($text); $time = date('Ymd',time()); $dir = "./data/img/number/".$time."/"; if(!is_dir($dir))mkdir($dir,0777); //上传目录不存在则创建 /* 绘制对象 */ $drawing = new BCGDrawing($dir.$text.".png", $colorFront); $drawing->setBarCode($code); $drawing->draw(); /* 作为文件下载 */ //header("Content-Type: image/png;"); //header("Content-Disposition:attachment;filename='barcode.png'"); $drawing->finish(BCGDrawing::IMG_FORMAT_PNG); return "/data/img/number/".$time."/".$text.".png"; } } //end class