public static ByteArrayOutputStream createQrImage(String content, int width, int height, String formatName){
ByteArrayOutputStream baos = null;
try{
baos = new ByteArrayOutputStream(4096);
Hashtable<EncodeHintType, Object> hintMap = new Hashtable<EncodeHintType, Object>();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);
hintMap.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hintMap.put(EncodeHintType.MARGIN, 0);
BitMatrix byteMatrix = new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, width, height, hintMap);
int matrixWidth = byteMatrix.getWidth();
BufferedImage image = new BufferedImage(matrixWidth, matrixWidth, BufferedImage.TYPE_INT_RGB);
image.createGraphics();
Graphics2D graphics = (Graphics2D) image.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, matrixWidth, matrixWidth);
graphics.setColor(Color.BLACK);
for (int i = 0; i < matrixWidth; i++) {
for (int j = 0; j < matrixWidth; j++) {
image.setRGB(i, j, byteMatrix.get(i, j) ? 0xFF000000 : 0xFFFFFFFF);
}
}
ImageIO.write(image, formatName, baos);
}catch(Exception ex){
ex.printStackTrace();
}
return baos ;
}
/**
*content 请求地址
*/
private byte[] createQrImage(String content) throws IOException {
byte[] img = null;
ByteArrayOutputStream baos = null;
try {
baos = YQISUtils.createQrImage(content, 360, 360, "png");
img = baos.toByteArray();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
if (baos != null) {
baos.close();
}
}
return img;
}
public void genimg(){
try {
byte[] imgs = this.createQrImage("https://com.cn/forwardTemperatureLogRegPage.do");
String imgname = "C:\\Users\\Muze Lin\\Downloads\\jiankanshenbao.jpg";
FileImageOutputStream imageOutput = new FileImageOutputStream(new File(imgname));//打开输入流
imageOutput.write(imgs, 0, imgs.length);//将byte写入硬盘
imageOutput.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static BitMatrix createBarcodeImageBitMatrix(String content ,int width , int heigth , Hashtable<EncodeHintType, Object> hintMap){
try{
if(hintMap == null){
hintMap = new Hashtable<EncodeHintType, Object>();
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.Q);
hintMap.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hintMap.put(EncodeHintType.MARGIN, 1);
}
BitMatrix byteMatrix = new MultiFormatWriter().encode(content,
BarcodeFormat.CODE_128, width, heigth, hintMap);
return byteMatrix ;
}catch(Exception ex){
ex.printStackTrace();
}
return null;
}
分享到:
相关推荐
labview QR code Generator2012,labview生成二维码的vi
qr代码源于日本 是用图形扫描方式存储信息 现在该技术已广泛应用于网络中 可以用便携设备读取信息 该文件可用于pc平台 将文本转化为QR Code QR Code QR Code QR Code QR Code
Unity3D 二维码插件 最新版, QR CodeBarcode Scanner and Generator--Cross PlatformPro.unitypackage
生成QR CODE的二维码JAVA源程序,包含2个文件压缩包
QR code二维码生成 本软件是 Swetake 有限公司的作品。禁止以盈利为目地进行销售、发布,以及私自窜改软件程序内容,允许自己转载、发布。
QR Code Generator Plugin for Photoshop即PS的二维码扩展插件,就是用来生成二维码的。需要安装到PS的滤镜目录中,在启动PS后从从滤镜EVEnX中调出该滤镜,支持CS6以下版本,如果你的PS版本较新,你需要在安装...
二维码生成、解密软件: Psytec QR Code Editor,常常用来暗藏信息,可以用这款软件做二人交流的秘密软件。
主要讲述QR Code二维条码的编码与图像处理技术,适合做为论文的参考材料
基于QR code的基层成教云校园服务平台.pdf
筆者最近就常常在想,到底什麼樣的產品包裝 QR Code,才算的上是有價值的?而 Jento 又能怎麼樣改革這樣產品包裝上的 QR Code? 今天,我們就來談談,一個好的產品包裝,怎麼樣運用 QR Code,做到最佳的虛實整合。 ...
基于VB 开发的QR Code打印程序,QR Code 由QR Marker控件生成,使用前先注册QR Marker控件(附VB代码 及 QR Marker控件/注册方法)
QR(Quick Response)是一种二维码,此资源是QR的java源代码,包含了QR的解码
通用的二维码QR码的基本原理,教你如何画一个二维码。
利用BlendMask實例分割模型與高斯-約旦消去法,將QR code與背景圖片做融合,產生有視覺意義的QR code。 根據ISO 18004:2015的規範,QR code定義了不同的版本(level)、容錯等級(correction level)。 根據版本、容錯...
QR CodeBarcode Scanner Generator是一个高效的代码扫描器和生成器工具,它运行跨平台,支持扫描QRCode,Code_128,Code_93,Code_39,EAN_13,EAN_8,Aztec代码,UPC-A,UPC-E,数据矩阵,PDF-417, RSS_14等,支持...
开题报告 - 基于android的QR Code二维条码生成扫描技术研究与实现.docx开题报告 - 基于android的QR Code二维条码生成扫描技术研究与实现.docx开题报告 - 基于android的QR Code二维条码生成扫描技术研究与实现.docx...
qr code 2
三星OEM应用,也可以扫描二维码,文本文档等,适用于windows8,很实用
本文针对QR code条码的标准文档国标GB/T18284—2000《快速响应矩阵码》, 介绍了QR code条码的特点和编解码规则,同时对编解码系统中用到的纠错码理论 进行了深入的研究,归纳出RS、BCH纠错码在QR code编解码中的...
51系列单片机生成二维码 keil环境,12864打点程序附赠,有清楚的使用方法,以及注释,都是通俗易懂的代码~