手机版

Oracle中生成二维码图片_V1.1_WEB(8)

时间:2025-07-07   来源:未知    
字号:

的信息越大

int size = 12;

qrcodeHandler.setQrcodeVersion(size);

System.out.println(content);

byte[] contentBytes = content.getBytes("gb2312");

// 图片尺寸

int imgSize = 67 + 12 * (size - 1);

BufferedImage bufImg = new BufferedImage(imgSize,

imgSize, BufferedImage.TYPE_INT_RGB);

Graphics2D gs = bufImg.createGraphics();

gs.setBackground(Color.WHITE);

gs.clearRect(0, 0, imgSize, imgSize);

// 设定图像颜色 > BLACK

gs.setColor(Color.BLACK);

// 设置偏移量 不设置可能导致解析出错

int pixoff = 2;

// 输出内容 > 二维码

if (contentBytes.length > 0 && contentBytes.length <800) {

boolean[][] codeOut =

qrcodeHandler.calQrcode(contentBytes);

for (int i = 0; i < codeOut.length; i++) {

for (int j = 0; j < codeOut.length; j++) {

if (codeOut[j][i]) {

gs.fillRect(j * 3 + pixoff, i * 3 +

pixoff, 3, 3);

}

}

}

} else {

System.err.println("QRCode content bytes length =

"

+ contentBytes.length + " not in [ 0,800 ].

");

//return "N";

}

Image img = ImageIO.read(new File(imgIcon));

gs.drawImage(img,

(imgSize-imgSize/6)/2,(imgSize-imgSize/6)/2,imgSize/6,imgSiz

e/6, null);

gs.dispose();

bufImg.flush();

//System.out.println("7");

File imgFile = new File(imgPath);

//System.out.println("8");

// 生成二维码QRCode图片

ImageIO.write(bufImg, "png", imgFile);

//System.out.println("9");

return "Y";

Oracle中生成二维码图片_V1.1_WEB(8).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)