|
|
@ -1,13 +1,5 @@ |
|
|
|
package com.epmet.commons.tools.utils; |
|
|
|
|
|
|
|
/** |
|
|
|
* desc: |
|
|
|
* |
|
|
|
* @author: LiuJanJun |
|
|
|
* @date: 2022/3/18 11:57 上午 |
|
|
|
* @version: 1.0 |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
import com.google.zxing.BarcodeFormat; |
|
|
|
import com.google.zxing.EncodeHintType; |
|
|
@ -28,7 +20,6 @@ import java.io.IOException; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
/** |
|
|
|
* Author 程鹏 |
|
|
|
* Date: 2021/08/27 16:01 |
|
|
|
* Description:二维码生成工具类 |
|
|
|
*/ |
|
|
@ -95,7 +86,7 @@ public class BarcodeUtils { |
|
|
|
//x开始的位置:(图片宽度-字体大小*字的个数)/2
|
|
|
|
int startX = (WIDTH - (FONTSIZE * pressText.length())) / 2; |
|
|
|
//y开始的位置:图片高度-(图片高度-图片宽度)/2
|
|
|
|
int startY = HEIGHT - (HEIGHT - WIDTH) / 2+ FONTSIZE; |
|
|
|
int startY = HEIGHT - (HEIGHT - WIDTH) / 2 + FONTSIZE; |
|
|
|
|
|
|
|
int imageW = outImage.getWidth(); |
|
|
|
int imageH = outImage.getHeight(); |
|
|
@ -169,9 +160,24 @@ public class BarcodeUtils { |
|
|
|
} else { |
|
|
|
return new String(btf, 0, len - 1, "GBK"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/*public static void main(String[] args) { |
|
|
|
try { |
|
|
|
BufferedImage image = BarcodeUtils.drawQRImage("小崽子社区中国国歌过过过过过所多对方水电费是的发生的", "https://epmet-cloud.elinkservice.cn/epmet-oper-gov/#/caiji/b058eb82d65d922fec9dc84f0348fc6a?name=%E5%B0%8F%E5%AF%A8%E5%AD%90%E7%A4%BE%E5%8C%BA&customerId=3fdd0380deff5b30f45376cdf995d1c1&type=community&userId=72d331139a5012b6bba18b40029a2755&123123123111"); |
|
|
|
//BufferedImage image = BarcodeUtils.drawQRImage("小崽子社区", "erId=72d331139a5012b6bba18b40029a2755&123123123111");
|
|
|
|
//BufferedImage image2 = BarcodeUtils.getQRCode("小崽子社区", "https://epmet-cloud.elinkservice.cn/epmet-oper-gov/#/caiji/b058eb82d65d922fec9dc84f0348fc6a?name=%E5%B0%8F%E5%AF%A8%E5%AD%90%E7%A4%BE%E5%8C%BA&customerId=3fdd0380deff5b30f45376cdf995d1c1&type=community&userId=72d331139a5012b6bba18b40029a2755&123123123111");
|
|
|
|
//BufferedImage 转 InputStream
|
|
|
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
|
|
|
ImageOutputStream imageOutput = ImageIO.createImageOutputStream(byteArrayOutputStream); |
|
|
|
ImageIO.write(image, "png", imageOutput); |
|
|
|
InputStream inputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); |
|
|
|
String s = "/Users/liujianjun/Downloads/t.png"; |
|
|
|
File file= new File(s); |
|
|
|
FileUtils.copyInputStreamToFile(inputStream, file); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|