Atitit.二维码功能的设计实践 attilax 总结

1.1. 二维码要实现的功能1

1.2. 现有二维码功能设计不足的地方(待改进)1

1.3. 二维码组件1

1.4. Java版  zxing类库..2

1.5. Php版 laveral框架版3

1.6. Phpqrcode框架版3

1.7. Qa集合与注意事项3

1.1. 二维码要实现的功能

显示二维码

保持二维码图片为文件

直接输出二维码图片流

Img 的src为二维码图片

一般要传递order_id 或者一个url参数为主。

1.2. 现有二维码功能设计不足的地方(待改进)

Java 与php的api 统一化

增加Js sdk

1.3. 二维码组件

Prj eform

<a href="{{ url('/qrcodeQ5/qrcode.php?url='.base64_encode($url)) }}">

<img class="img-res bd" style="max-width:250px" src="{{ url('/qrcodeQ5/qrcode.php?url='.base64_encode($url)) }}" alt="...">

</a>

作者::  ★(attilax)>>>   绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 汉字名:艾龙,  EMAIL:1466519819@qq.com

转载请注明来源: http://www.cnblogs.com/attilax/

1.4. Java版  zxing类库..

#-----com.xx.share.sharex.java

public   String gene(String code) {
        String qrcodedir = "qrcodeO5/"+filex.getUUidName()+".jpg";
    
        String path=pathx.webAppPath() + "/" + qrcodedir;
        filex.createAllPath(path);
        core.log("--qrcode path:"+path);
    // attilax 老哇的爪子  下午5:30:42   2014年5月11日 
      qrcodex.    gene(code, path, 250, 250);
      return qrcodedir;
    }

#----com.attilax.qrcode.qrcodex.javar

public static void gene(final String content, final String path,
            final int width, final int height) {
        new tryX<Object>() {

@Override
            public Object item(Object t) throws Exception {
                // attilax 老哇的爪子  下午5:23:26   2014年5月11日 
                   MultiFormatWriter multiFormatWriter = new MultiFormatWriter();
                     
                     Map hints = new HashMap();
                     hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
                 
                    BitMatrix bitMatrix = multiFormatWriter.encode(content, BarcodeFormat.QR_CODE, width, height,hints);
                     File file1 = new File(path );
                     MatrixToImageWriter.writeToFile(bitMatrix, "jpg", file1);
                return null;
            }
        }.$("");
    }

1.5. Php版 laveral框架版

    ob_clean();//清除输出

 $image=QrCode::format('png')->merge('/public/'.CDN_IMG.'logo.png', .3)->margin(2)->size(200)->color(0,0,0)->backgroundColor(255,255,255)->encoding('UTF-8')->generate($url);

return response()->make($image, 200, [

            'content-type' => 'image/png',

        ]);

1.6. Phpqrcode框架版

 

<?php

$url=base64_decode($_GET["url"]);

include 'phpqrcode/phpqrcode.php';

//QRcodeQ5::png('code data text', 'filename.png'); // creates file

QRcodeQ5::png($url);

 

//QRcodeQ5::png('some othertext 1234'); // creates code image and outputs it directly into browser

//输出图片   

//imagepng($QR, 'helloweixin.png');   

?>

 

 

1.7. Qa集合与注意事项

输出png的图片不能正常显示,这个通常是bom头造成的,某一个类库php是utf8格式的,而生成qrcode的php界面include了它。。。最简单的解决方案是

先用   ob_clean();//清除输出,一般就可,但在laveral框架下,任然不可。。

就把生成qrcode的php组件独立出来,然后通过img的src调用。。即可。。

 

参考

atitit.二维码生成总结java zxing - attilax的专栏 - 博客频道 - CSDN.NET.html

最新文章

  1. MySQL 外键
  2. 模-数(A/D)转换器
  3. xcode 插件之KSImageNamed-Xcode
  4. typecho插件编写教程1 - 从HelloWorld说起
  5. iOS开发——UI篇Swift篇&amp;UIAlertView/UIActionSheet
  6. Struts2 result type
  7. 【iOS与EV3混合机器人编程一系列五个】iOS_WiFi_EV3_Library 解剖连接EV3
  8. UIAlertController 自定义输入框及KVO监听
  9. Special Fish
  10. 8.String StringBuffer StringBuilder
  11. 39.Odoo产品分析 (四) – 工具板块(8) – 生产力(1)
  12. struct和union,enum分析
  13. JSP概述、API、注释
  14. 方程整数解-2015省赛C语言A组第一题
  15. Linux chattr 命令详解
  16. ZT pthread_cleanup_push()/pthread_cleanup_pop()的详解
  17. OK335xS 256M 512M nand flash make ubifs hacking
  18. 【医学影像】《Identifying Medical Diagnoses and Treatable Diseases by Image-Based Deep Learning》论文笔记
  19. SQL Server -&gt;&gt; 校检函数CHECKSUM、CHECKSUM_AGG、BINARY_CHECKSUM和HASHBYTES
  20. 【洛谷 P3187】 [HNOI2007]最小矩形覆盖 (二维凸包,旋转卡壳)

热门文章

  1. POJ 2187 Beauty Contest (求最远点对,凸包+旋转卡壳)
  2. void fun() const{}; const void fun(){}; 和void const fun(){}; 的区别?
  3. 事务内执行sql修复的简易模板
  4. phantomjs 无法打开https网站解决方案
  5. ubuntu 的runlevel设定
  6. DefaultMessageStore-CommitLog-MapedFileQueue.allocateMapedFileService初始化链
  7. DotNetBar ComboBoxEx
  8. Java Nio Socket通讯
  9. Tomcat从零开始(十七)——StandardWrapper
  10. jQuery EasyUI API 中文文档 - 表单(form补充)