当前位置:网站首页>How to generate QR code
How to generate QR code
2022-06-21 09:05:00 【No repair at night】
public class QRCodeUtils {
public static void createQRCode(String content){
boolean[][]bs = getBooleansByTool(content);
int width = 400;
int height = 400;
BufferedImage bufferedImage = new BufferedImage(width,height,1);
Graphics2D gg = bufferedImage.createGraphics();
gg.setBackground(Color.white);
gg.fillRect(0,0,width,height);
gg.setColor(Color.black);
int lon = 3;
for(int i=0;i<bs.length;i++){
for(int j=0;j<bs.length;j++){
if(bs[i][j]){
gg.fillRect(i*lon,j*lon,lon,lon);
}
}
}
String path="####";
try {
ImageIO.write(bufferedImage,"jpg",new File(path));
} catch (
IOException e) {
e.printStackTrace();
}
System.out.println(" success ");
}
public static boolean [][] getBooleansByTool(String content){
boolean [][] bs = null;
Qrcode qrcode = new Qrcode();
qrcode.setQrcodeEncodeMode('B');
qrcode.setQrcodeErrorCorrect('M');
qrcode.setQrcodeVersion(20);
try {
bs=qrcode.calQrcode(content.getBytes("utf-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return bs;
}
}path Just fill in your own path with the contents of , Concrete jar Package on my home page , You need to take it yourself QRCode rely on
边栏推荐
- Unity write multithreading considerations
- 请问这些要求用mysql能实现吗
- Requirements for setting up points sign in tasks and common problems in the process of building points mall
- The next stop of Intelligent Manufacturing: cloud native + edge computing two wheel drive
- The skill of using ADB and the principle of USB communication
- Talking about Festinger effect
- Waiting in webdriver
- Unity's network request_ Short connection
- doc常用语法,更新中……
- 【VS】【使用问题】【解决方案】VS2010打开一直停留在启动界面
猜你喜欢
![[vs], [usage problem], [solution] when VS2010 is opened, it stays in the startup interface](/img/04/a7455760caa4fc0480a034de1e24b8.png)
[vs], [usage problem], [solution] when VS2010 is opened, it stays in the startup interface

Understanding and use of advanced pointer

How to connect the Internet - FTTH

Audio immersive experience

Abstractqueuedsynchronizer (AQS) source code detailed analysis - semaphore source code analysis

The difference between tuples and lists

Figure out how MySQL works

Client construction and Optimization Practice

【VS】【使用问题】【解决方案】VS2010打开一直停留在启动界面

Tidb3.0- 4.0 memory control / modification log saving days / maximum index length
随机推荐
Improve code checking with annotations
[DB written interview 225] in Oracle, if the online redo log file is damaged, how to recover it?
TiDB3.0- 4.0 内存控制/修改日志保存天数/最大索引长度
STL教程2-MyArray框架实现
Unity write multithreading considerations
C#中的list操作入门
Unity's network request_ Short connection
Storage of C language integer in memory
tidb4.0.0遇见的问题、报错总结(tiup部署)
Generic functions in kotlin
Abstractqueuedsynchronizer (AQS) source code detailed analysis - lock competitive resource analysis
应用配置管理,基础原理分析
Summary of Web automated testing
积分签到任务设置的要求,积分商城搭建过程中常见的问题
利用注解改进代码检查
南京理工大学MOOC慕课:程序设计基础(Ⅰ)第8章测试选择题答案及解析
Character function and string function
Dumpling备份数据库
Unity development related blog collection
Retrofit extended reading