亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

QRCODE

byte[] d = qrData.getBytes("gd2312");


qrDate是錯的,識別不了

正在回答

2 回答

public?static?void?main(String[]?args)?throws?IOException?{
		Qrcode?xQrcode?=?new?Qrcode();
		xQrcode.setQrcodeEncodeMode('B');//N代表數字,A代表a-Z,B代表其他字符
		xQrcode.setQrcodeErrorCorrect('M');//糾錯等級
		xQrcode.setQrcodeVersion(7);//版本
		String?qrData?=?"www.xianlaiwan.cn";
		int?width?=?67?+?12?*?(?7?-?1?);//7是版本
		int?height?=?67?+?12?*?(?7?-?1?);
		
		BufferedImage?bufferedImage?=?new?BufferedImage(width,?height,?BufferedImage.TYPE_INT_RGB);
		
		Graphics2D?gs?=?bufferedImage.createGraphics();
		
		gs.setBackground(Color.white);
		gs.setColor(Color.BLACK);
		gs.clearRect(0,?0,?width,?height);
		
		int?pixoff?=?2;//偏移量
		
		byte[]?d?=?qrData.getBytes("gb2312");
		if(d.length>0?&&?d.length<120){
			boolean[][]?s?=?xQrcode.calQrcode(d);
			
			for(int?i=0;i<s.length;i++){
				for(int?j=0;j<s.length;j++){
					if(s[j][i]){
						gs.fillRect(j*3+pixoff,?i*3+pixoff,?3,?3);
					}
				}
			}
		}
		
		gs.dispose();
		bufferedImage.flush();
		
		ImageIO.write(bufferedImage,?"png",?new?File("c:/image2.png"));
	}


0 回復 有任何疑惑可以回復我~

public static void main(String[] args) throws IOException {

Qrcode xQrcode = new Qrcode();

xQrcode.setQrcodeEncodeMode('B');//N代表數字,A代表a-Z,B代表其他字符

xQrcode.setQrcodeErrorCorrect('M');//糾錯等級

xQrcode.setQrcodeVersion(7);//版本

String qrData = "www.xianlaiwan.cn";

int width = 67 + 12 * ( 7 - 1 );//7是版本

int height = 67 + 12 * ( 7 - 1 );

BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

Graphics2D gs = bufferedImage.createGraphics();

gs.setBackground(Color.white);

gs.setColor(Color.BLACK);

gs.clearRect(0, 0, width, height);

int pixoff = 2;//偏移量

byte[] d = qrData.getBytes("gb2312");

if(d.length>0 && d.length<120){

boolean[][] s = xQrcode.calQrcode(d);

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

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

if(s[j][i]){

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

}

}

}

}

gs.dispose();

bufferedImage.flush();

ImageIO.write(bufferedImage, "png", new File("c:/image2.png"));

}



0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號