資源簡介
開發(fā)環(huán)境:ecplice
jdk:>=1.5
語言:java
功能:二維碼生成。
這是我自己根據(jù)二維碼生成算法的描述寫的代碼,純java不需要依賴dll等。
對二維碼生成算法有興趣的童鞋可以下載學習一下,順便給我點積分。嘿嘿。

代碼片段和文件信息
import?java.awt.Color;
import?java.awt.Graphics;
import?javax.swing.JButton;
import?javax.swing.Jframe;
import?person.wangchen11.qrcode.QRCode;
/**
?*?java?二維碼生成demo圖形版?
?*?
?*?@author?wangchen11望塵11??
?*
?*/
public?class?QRCodeGUI?extends?Jframe{
/**
?*?
?*/
private?static?final?long?serialVersionUID?=?1L;
QRCodeView?mQrCodeView;
public?QRCodeGUI()?{
mQrCodeView=new?QRCodeView();
String?str=“望塵11作品!!!望塵11作品!!!望塵11作品!!!望塵11作品!!!望塵11作品!!!望塵11作品!!!望塵11作品!!!望塵11作品!!!望塵11作品!!!望塵11作品!!!“;
QRCode?qrCode=QRCode.autoEncodeString(str.getBytes()?str.getBytes().length?QRCode.ERROR_CORRECTION_LEVEL_H?0?0);
mQrCodeView.setQRCode(qrCode);
getContentPane().add(mQrCodeView);
setSize(260?260);
setLocation(500?300);
setVisible(true);
this.setResizable(true);
this.settitle(“size:“+qrCode.getSize()+“ver:“+qrCode.getVersion());
}
public?static?void?main(String[]?args)?{
new?QRCodeGUI();
}
}
class?QRCodeView?extends?JButton
{
/**
?*?
?*/
private?static?final?long?serialVersionUID?=?1L;
QRCode?mQRCode=null;
public?void?setQRCode(QRCode?qrCode)
{
mQRCode=qrCode;
}
@Override
public?void?paint(Graphics?g)?{
if(mQRCode==null)
return?;
g.setColor(Color.WHITE);
g.clearRect(0?0?getWidth()?getHeight());
g.setColor(Color.BLACK);
int?space=getWidth() space/=(mQRCode.getSize()+2);
for(int?i=0;i {
int?y=(i+1)*space;
for(int?j=0;j {
int?x=(j+1)*space;
if(mQRCode.isBlack(j?i))
g.fillRect(x?y?space?space);
}
}
}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2016-02-16?18:45??QRCode\
?????文件?????????299??2016-02-15?11:12??QRCode\.classpath
?????文件?????????382??2016-02-14?17:49??QRCode\.project
?????目錄???????????0??2016-02-14?15:42??QRCode\.settings\
?????文件?????????598??2016-02-15?11:12??QRCode\.settings\org.eclipse.jdt.core.prefs
?????目錄???????????0??2016-02-16?15:21??QRCode\bin\
?????文件????????1778??2016-02-16?18:43??QRCode\bin\QRCodeGUI.class
?????文件????????1275??2016-02-16?18:43??QRCode\bin\QRCodeView.class
?????目錄???????????0??2016-02-15?11:12??QRCode\bin\person\
?????目錄???????????0??2016-02-15?11:12??QRCode\bin\person\wangchen11\
?????目錄???????????0??2016-02-15?15:40??QRCode\bin\person\wangchen11\qrcode\
?????文件?????????644??2016-02-16?18:42??QRCode\bin\person\wangchen11\qrcode\Block.class
?????文件????????1172??2016-02-16?18:41??QRCode\bin\person\wangchen11\qrcode\Main.class
?????文件???????12104??2016-02-16?18:42??QRCode\bin\person\wangchen11\qrcode\QRCode.class
?????文件????????4675??2016-02-15?11:12??QRCode\bin\person\wangchen11\qrcode\QREccSpec.class
?????文件?????????813??2016-02-15?11:12??QRCode\bin\person\wangchen11\qrcode\QRFormatInfo.class
?????文件????????2912??2016-02-16?18:39??QRCode\bin\person\wangchen11\qrcode\QRSpec.class
?????文件?????????955??2016-02-15?15:42??QRCode\bin\person\wangchen11\qrcode\QRVersionPattern.class
?????目錄???????????0??2016-02-15?11:12??QRCode\bin\person\wangchen11\rscode\
?????文件????????1515??2016-02-16?17:09??QRCode\bin\person\wangchen11\rscode\Main.class
?????文件????????2937??2016-02-16?17:47??QRCode\bin\person\wangchen11\rscode\RS.class
?????目錄???????????0??2016-02-16?15:01??QRCode\src\
?????文件????????1742??2016-02-16?18:43??QRCode\src\QRCodeGUI.java
?????目錄???????????0??2016-02-14?15:42??QRCode\src\person\
?????目錄???????????0??2016-02-15?09:27??QRCode\src\person\wangchen11\
?????目錄???????????0??2016-02-15?15:40??QRCode\src\person\wangchen11\qrcode\
?????文件?????????662??2016-02-16?18:41??QRCode\src\person\wangchen11\qrcode\Main.java
?????文件???????18665??2016-02-16?18:42??QRCode\src\person\wangchen11\qrcode\QRCode.java
?????文件????????3498??2016-02-15?10:46??QRCode\src\person\wangchen11\qrcode\QREccSpec.java
?????文件?????????626??2016-02-15?10:06??QRCode\src\person\wangchen11\qrcode\QRFormatInfo.java
?????文件????????3542??2016-02-16?18:39??QRCode\src\person\wangchen11\qrcode\QRSpec.java
............此處省略5個文件信息
評論
共有 條評論