產生二維碼方法匯總,匯總

來源:互聯網
上載者:User

產生二維碼方法匯總,匯總

隨著網路的迅速發展 發展 發展,二維碼的應用將會越來越多。同時很多隻是很平凡的二維碼,請拿起你的手 把這個二維碼 設計起來吧。下面分享了幾個非常好的二維碼設計。

二維碼原理:

二維條碼/二維碼可以分為堆疊式/行排式二維條碼和矩陣式二維條碼。 堆疊式/行排式二維條碼形態上是由多行短截的一維5條碼堆疊而成;矩陣式二維條碼以矩陣的形式組成,在矩陣相應元素位置上用“點”表示二進位“1”, 用“空”表示二進位“0”,“點”和“空”的排列組成代碼。

最近對二維碼產生了興趣 研究了一下二維碼 這裡生出的術語 qrcode  容錯性較高。

資料表示方法

深色模組表示二進位“1”,淺色模組表示二進位“0”。
錯誤修正能力
· L級:約可錯誤修正7%的資料碼字
· M級:約可錯誤修正15%的資料碼字
· Q級:約可錯誤修正25%的資料碼字
· H級:約可錯誤修正30%的資料碼字

上面的設計 就很完美的利用了 qrcode的容錯性,非常nice  也非常有創意!!

1.google 介面

複製代碼 代碼如下:
<?php
               $urlToEncode="http://www.csd2n.net";//要產生二維碼的網址
               generateQRfromGoogle($urlToEncode);
               function generateQRfromGoogle($chl,$widhtHeight ='150',$EC_level='L',$margin='0')
               {
               $url = urlencode($url);
               echo '<img src="http://chart.apis.google.com/chart?chs='.$widhtHeight.'x'.$widhtHeight.'&cht=qr&chld='.$EC_level.'|'.$margin.'&chl='.$chl.'" alt="QR code" widhtHeight="'.$size.'" widhtHeight="'.$size.'"/>';//Google API介面,若失效可到Google網址查詢最新介面
               }
               ?>
  

2..js代碼 轉換為 canvas (重點)

demo: http://hxend.com/jsqrcode/test/

複製代碼 代碼如下:
<script type="text/javascript" src="http://sandbox.runjs.cn/uploads/rs/142/gjxgxu0g/qrgen.min.js"></script>
               <div id=qrcode></div>
               <script type="text/javascript">
               qrcode(document.getElementById('qrcode'),{
                   data:'http://geraldl.net'
               });
               </script>
  

3. 圖片介面

複製代碼 代碼如下:
<img src="http://qrcoder.sinaapp.com?t=hello world">

4.demo 裡面http://hxend.com/jsqrcode/test/ 代碼

複製代碼 代碼如下:
<!doctype html>
<html>
    <head>
        <title>QRCode</title>
        <script type="text/javascript" src="http://files.cnblogs.com/webers/qrcode-light.js"></script>
        <script type="text/javascript" src="http://files.cnblogs.com/webers/qrgen.js"></script>
    </head>
    <body>
        <div>
            <h1>二維碼產生</h1>
            <div>
                圖片: <img id=qrimg src=http://www.bkjia.com/uploadfile/2014/1219/20141219081025437.png>
                <label><input id=qrclearedges type=checkbox checked>清理邊緣</label>
            </div>
            <div><input id=fimg type=file></div>
            <div>文本: <textarea id=qrtext>http://www.btgoogle.com</textarea></div>
            <div>大小: <input id=cellSize type=range min=2 max=10 value=6></div>
            <table>
                <tr>
                    <td rowspan=2>效果:</td>
                    <td colspan=3><input id=cellEffect type=range min=-50 max=50 step=5 value=0></td>
                </tr>
                <tr id=cellEffectStops>
                    <td align=left><a href=# data=l>液體</a></td>
                    <td align=center><a href=# data=s>方塊</a></td>
                    <td align=right><a href=# data=r>圓</a></td>
                </tr>
            </table>
            <div>
                Foreground color: <input id=colorFore type=color value=#4169e1>
                Background color: <input id=colorBack type=color value=#ffffff><br>
                Outside-border color: <input id=colorOut type=color value=#cd5c5c>
                Inside-border color: <input id=colorIn type=color value=#191970>
            </div>
            <button id=qrgen>產生</button>
        </div>
        <div id=qrcode></div>
        <script src="http://files.cnblogs.com/webers/take.js"></script>
    </body>

以上4種方法,第3種最簡單,第二種是我推薦的,自由度大些,小夥伴根據自己的需求來選擇吧

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.