四虎精品视频-四虎精品成人免费网站-四虎黄色网-四虎国产视频-国产免费91-国产蜜臀97一区二区三区

php生成EAN_13標(biāo)準(zhǔn)條形碼實(shí)例

下面的就是生成EAN_13標(biāo)準(zhǔn)的條碼的php方法,需要php+gd 環(huán)境 
  復(fù)制代碼 代碼如下:<?
function EAN_13($code) {
  //一個單元的寬度
  $lw = 2;
  //條碼高 
  $hi = 100;
  // the guide code is no coding,is used to show the left part coding type//
  // Array guide is used to record the EAN_13 is left part coding type//
  $Guide = array(1=>'AAAAAA','AABABB','AABBAB','ABAABB','ABBAAB','ABBBAA','ABABAB','ABABBA','ABBABA');
  $Lstart ='101';
  $Lencode = array("A" => array('0001101','0011001','0010011','0111101','0100011','0110001','0101111','0111011','0110111','0001011'),
                   "B" => array('0100111','0110011','0011011','0100001','0011101','0111001','0000101','0010001','0001001','0010111'));
  $Rencode = array('1110010','1100110','1101100','1000010','1011100',
                   '1001110','1010000','1000100','1001000','1110100');    

  $center = '01010';

  $ends = '101';
  if ( strlen($code) != 13 )
   { die("UPC-A Must be 13 digits."); }
$lsum =0;
$rsum =0;
  for($i=0;$i<(strlen($code)-1);$i++)
  {
    if($i % 2)
{
 // $odd += $ncode[$x]
  $lsum +=(int)$code[$i];
 }else{
  $rsum +=(int)$code[$i];
 }

  }
  $tsum = $lsum*3 + $rsum;
    if($code[12] != (10-($tsum % 10)))
{
   die("the code is bad!");
    } 

 // echo $Guide[$code[0]];
  $barcode = $Lstart;
  for($i=1;$i<=6;$i++)
  {
    $barcode .= $Lencode [$Guide[$code[0]][($i-1)]] [$code[$i]];
  }
  $barcode .= $center;

  for($i=7;$i<13;$i++)
  {
    $barcode .= $Rencode[$code[($i)]] ;
  }
  $barcode .= $ends;

    $img = ImageCreate($lw*95+60,$hi+30);
  $fg = ImageColorAllocate($img, 0, 0, 0);
  $bg = ImageColorAllocate($img, 255, 255, 255);
  ImageFilledRectangle($img, 0, 0, $lw*95+60, $hi+30, $bg);
  $shift=10;
  for ($x=0;$x<strlen($barcode);$x++) {
    if (($x<4) || ($x>=45 && $x<50) || ($x >=92)) 
  { 
    $sh=10; 
  } else { 
    $sh=0; 
  }
    if ($barcode[$x] == '1') 

  $color = $fg;
    } else { 
  $color = $bg; 
}
    ImageFilledRectangle($img, ($x*$lw)+30,5,($x+1)*$lw+29,$hi+5+$sh,$color);
  }
  /* Add the Human Readable Label */
  ImageString($img,5,20,$hi+5,$code[0],$fg);
  for ($x=0;$x<6;$x++) {
    ImageString($img,5,$lw*(8+$x*6)+30,$hi+5,$code[$x+1],$fg);
    ImageString($img,5,$lw*(53+$x*6)+30,$hi+5,$code[$x+7],$fg);
  }
 // ImageString($img,4,$lw*95+17,$hi-5,$code[12],$fg);
  /* Output the Header and Content. */
  header("Content-Type: image/png");
  ImagePNG($img);

}

EAN_13('6901028055048');

?> 

php技術(shù)php生成EAN_13標(biāo)準(zhǔn)條形碼實(shí)例,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 爱情买卖网站 电影| 未来少年柯南 动漫| 美女xxx69爽爽免费观妞| 北京卫视电视节目单| 复仇者联盟4在线完整版观看| 贝加尔湖畔钢琴谱| 夜魔3| 忏悔三昧念3遍| 三年级片| 玉林电视台| 公共安全教育第一课| 林正英演的全部电影| 今晚打老虎| 疯狂试爱二| 挠中国美女丝袜脚心| 美国要塞1986| 二年级数学下册期末测试卷| 午夜高清影院| cctv16直播| 失落之城电影| 普通日记200字可抄| 火舞俪人 电影| 黄秋生的电影| 视频www| juliet stevenson| 宁波电视台| 啊摇篮电影| 2024年怀男怀女表图| 缉私群英 电视剧| 爱在西元前简谱| 吉泽明步番号| 璐·德·拉格| 砌体工程质量验收规范gb50203---2011| 嫩草在线视频| 宣彤电影| 男生魔鬼训练压腿| 周传基| 蜜桃成熟时免费视频| 男上女下动态视频| 姑娘主动把生米煮成熟饭| 龙的新娘电视剧全集|