<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[ECMall Ecmall二次开发 - PHP技术-]]></title> 
<link>http://www.laohucheng.com/index.php</link> 
<description><![CDATA[ECMall,ECMall二次开发,厦门PHP-ECShop二次开发,ECShop开发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[ECMall Ecmall二次开发 - PHP技术-]]></copyright>
<item>
<link>http://www.laohucheng.com/post//</link>
<title><![CDATA[PHP生成条形码 图形处理]]></title> 
<author>noel &lt;babysir@qq.com&gt;</author>
<category><![CDATA[程序 代码 源码]]></category>
<pubDate>Sat, 11 Apr 2009 01:30:21 +0000</pubDate> 
<guid>http://www.laohucheng.com/post//</guid> 
<description>
<![CDATA[ 
	PHP生成条形码 图形处理<br/><br/><br/>&lt;?php <br/>function UPCAbarcode($code) &#123; <br/>&nbsp;&nbsp;$lw = 2; $hi = 100; <br/>&nbsp;&nbsp;$Lencode = array(&#039;0001101&#039;,&#039;0011001&#039;,&#039;0010011&#039;,&#039;0111101&#039;,&#039;0100011&#039;, <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039;0110001&#039;,&#039;0101111&#039;,&#039;0111011&#039;,&#039;0110111&#039;,&#039;0001011&#039;); <br/>&nbsp;&nbsp;$Rencode = array(&#039;1110010&#039;,&#039;1100110&#039;,&#039;1101100&#039;,&#039;1000010&#039;,&#039;1011100&#039;, <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039;1001110&#039;,&#039;1010000&#039;,&#039;1000100&#039;,&#039;1001000&#039;,&#039;1110100&#039;); <br/>&nbsp;&nbsp;$ends = &#039;101&#039;; $center = &#039;01010&#039;; <br/>&nbsp;&nbsp;/* UPC-A Must be 11 digits, we compute the checksum. */ <br/>&nbsp;&nbsp;if ( strlen($code) != 11 ) &#123; die(&quot;UPC-A Must be 11 digits.&quot;); &#125; <br/>&nbsp;&nbsp;/* Compute the EAN-13 Checksum digit */ <br/>&nbsp;&nbsp;$ncode = &#039;0&#039;.$code; <br/>&nbsp;&nbsp;$even = 0; $odd = 0; <br/>&nbsp;&nbsp;for ($x=0;$x&lt;12;$x++) &#123; <br/>&nbsp;&nbsp;&nbsp;&nbsp;if ($x % 2) &#123; $odd += $ncode[$x]; &#125; else &#123; $even += $ncode[$x]; &#125; <br/>&nbsp;&nbsp;&#125; <br/>&nbsp;&nbsp;$code.=(10 - (($odd * 3 + $even) % 10)) % 10; <br/>&nbsp;&nbsp;/* Create the bar encoding using a binary string */ <br/>&nbsp;&nbsp;$bars=$ends; <br/>&nbsp;&nbsp;$bars.=$Lencode[$code[0]]; <br/>&nbsp;&nbsp;for($x=1;$x&lt;6;$x++) &#123; <br/>&nbsp;&nbsp;&nbsp;&nbsp;$bars.=$Lencode[$code[$x]]; <br/>&nbsp;&nbsp;&#125; <br/>&nbsp;&nbsp;$bars.=$center; <br/>&nbsp;&nbsp;for($x=6;$x&lt;12;$x++) &#123; <br/>&nbsp;&nbsp;&nbsp;&nbsp;$bars.=$Rencode[$code[$x]]; <br/>&nbsp;&nbsp;&#125; <br/>&nbsp;&nbsp;$bars.=$ends; <br/>&nbsp;&nbsp;/* Generate the Barcode Image */ <br/>&nbsp;&nbsp;$img = ImageCreate($lw*95+30,$hi+30); <br/>&nbsp;&nbsp;$fg = ImageColorAllocate($img, 0, 0, 0); <br/>&nbsp;&nbsp;$bg = ImageColorAllocate($img, 255, 255, 255); <br/>&nbsp;&nbsp;ImageFilledRectangle($img, 0, 0, $lw*95+30, $hi+30, $bg); <br/>&nbsp;&nbsp;$shift=10; <br/>&nbsp;&nbsp;for ($x=0;$x&lt;strlen($bars);$x++) &#123; <br/>&nbsp;&nbsp;&nbsp;&nbsp;if (($x&lt;10) &#124;&#124; ($x&gt;=45 &amp;&amp; $x&lt;50) &#124;&#124; ($x &gt;=85)) &#123; $sh=10; &#125; else &#123; $sh=0; &#125; <br/>&nbsp;&nbsp;&nbsp;&nbsp;if ($bars[$x] == &#039;1&#039;) &#123; $color = $fg; &#125; else &#123; $color = $bg; &#125; <br/>&nbsp;&nbsp;&nbsp;&nbsp;ImageFilledRectangle($img, ($x*$lw)+15,5,($x+1)*$lw+14,$hi+5+$sh,$color); <br/>&nbsp;&nbsp;&#125; <br/>&nbsp;&nbsp;/* Add the Human Readable Label */ <br/>&nbsp;&nbsp;ImageString($img,4,5,$hi-5,$code[0],$fg); <br/>&nbsp;&nbsp;for ($x=0;$x&lt;5;$x++) &#123; <br/>&nbsp;&nbsp;&nbsp;&nbsp;ImageString($img,5,$lw*(13+$x*6)+15,$hi+5,$code[$x+1],$fg); <br/>&nbsp;&nbsp;&nbsp;&nbsp;ImageString($img,5,$lw*(53+$x*6)+15,$hi+5,$code[$x+6],$fg); <br/>&nbsp;&nbsp;&#125; <br/>&nbsp;&nbsp;ImageString($img,4,$lw*95+17,$hi-5,$code[11],$fg); <br/>&nbsp;&nbsp;/* Output the Header and Content. */ <br/>&nbsp;&nbsp;header(&quot;Content-Type: image/png&quot;); <br/>&nbsp;&nbsp;ImagePNG($img); <br/>&#125; <br/>?&gt; <br/><hr/><br/><br/>函数描述及例子<br/><br/>&lt;? <br/>UPCAbarcode(&#039;47101496236&#039;); <br/>?&gt; <br/><br/><br/><br/>Tags - <a href="http://www.laohucheng.com/tags/php%25E7%2594%259F%25E6%2588%2590%25E6%259D%25A1%25E5%25BD%25A2%25E7%25A0%2581/" rel="tag">php生成条形码</a> , <a href="http://www.laohucheng.com/tags/%25E5%259B%25BE%25E5%25BD%25A2%25E5%25A4%2584%25E7%2590%2586/" rel="tag">图形处理</a>
]]>
</description>
</item><item>
<link>http://www.laohucheng.com/post//#blogcomment</link>
<title><![CDATA[[评论] PHP生成条形码 图形处理]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.laohucheng.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>