java 生成二维码工具

二维码生成

Gitee: https://gitee.com/iherus/qrext4j

一个简单易用的二维码生成器,可以自定义二维码颜色和码眼的样式。

运行环境:

JDK_1.8及以上,由于此生成器引用了部分JDK_1.8的特性,如需兼容JDK_1.7,可以通过修改少许代码实现。

Maven坐标:

org.iherus

qrext4j

1.3.0

QrcGen接口及使用说明:

eg_1:默认配置

-->writeToFile:

String content = "https://baike.baidu.com/item/%E5%97%B7%E5%A4%A7%E5%96%B5/19817560?fr=aladdin";

new SimpleQrcodeGenerator().generate(content).toFile("F:\\AodaCat_default.png");

-->writeToStream:

OutputStream out = null;

try {

out = new FileOutputStream("F:\\AodaCat_default.png");

new SimpleQrcodeGenerator().generate(content).toStream(out);

} finally {

IOUtils.closeQuietly(out);

}

效果如下:

eg_2:本地 Logo

String content = "https://baike.baidu.com/item/%E5%97%B7%E5%A4%A7%E5%96%B5/19817560?fr=aladdin";

new SimpleQrcodeGenerator().setLogo("F:\\AodaCat-1.png").generate(content).toFile("F:\\AodaCat_local_logo.png");

效果如下:

eg_3:在线 Logo

String content = "https://www.apple.com/cn/";

String logoUrl = "http://www.demlution.com/site\_media/media/photos/2014/11/06/3JmYoueyyxS4q4FcxcavgJ.jpg";

new SimpleQrcodeGenerator().setRemoteLogo(logoUrl).generate(content).toFile("F:\\Apple_remote_logo.png");

效果如下:

eg_4:自定义配置

QrcodeConfig config = new QrcodeConfig()

.setBorderSize(2)

.setPadding(10)

.setMasterColor("#00BFFF")

.setLogoBorderColor("#B0C4DE");

String content = "https://baike.baidu.com/item/%E5%97%B7%E5%A4%A7%E5%96%B5/19817560?fr=aladdin";

new SimpleQrcodeGenerator(config).setLogo("F:\\AodaCat-1.png").generate(content).toFile("F:\\AodaCat_custom.png");

效果如下:

eg_5:自定义码眼样式(v1.3.0_Snapshot)

QrcodeConfig config = new QrcodeConfig()

.setBorderSize(2)

.setPadding(10)

.setMasterColor("#778899")

.setLogoBorderColor("#B0C4DE")

.setCodeEyesPointColor("#BC8F8F")

.setCodeEyesFormat(QreyesFormat.DR2_BORDER_C_POINT);

String content = "https://baike.baidu.com/item/%E5%97%B7%E5%A4%A7%E5%96%B5/19817560?fr=aladdin";

new SimpleQrcodeGenerator(config).setLogo("F:\\AodaCat-1.png").generate(content).toFile("F:\\AodaCat_custom.png");

效果如下:

更多例子请看:

http://git.oschina.net/iherus/qrext4j/blob/master/src/test/java/org/iherus/example/TestQrGen.java

Features

欢迎提出更好的意见,帮助完善 QrcGen。

Copyright

Apache License, Version 2.0

https://www.aliyun.com/acts/product-section-2019/new-users?userCode=q3tq2yrp

—————————————————————————————————————

评论

h
hw_7864

⭐️ Admin快速开发: https://show.cool-admin.com/

赞 0
h
hw_7864

⭐️ 官方文档: https://cool-js.com

赞 0
h
hw_7864

⭐️ chatgpt在线体验: https://cool-js.com/ai/chat-vip/index.html?r=helloworld

赞 0