package demo;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Hashtable;
import javax.imageio.ImageIO;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.DecodeHintType;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.HybridBinarizer;
/**
 * 将二维码解析为文字
 */
public class Decoder {
	public static void main(String[] args) {
		BufferedImage bufferedImage = null;
		try {
			bufferedImage = ImageIO.read(new File("F:/二维码文件.gif"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		LuminanceSource source = new BufferedImageLuminanceSource(bufferedImage);
		BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
		Hashtable<DecodeHintType, String> hints = new Hashtable<DecodeHintType, String>();
		hints.put(DecodeHintType.CHARACTER_SET, "GBK");
		Result result = null;
		try {
			result = new MultiFormatReader().decode(bitmap, hints);
		} catch (NotFoundException e) {
			e.printStackTrace();
		}
		System.out.println(result.toString());
	}
}
最近下载更多
dzlwindy  LV8 2023年7月10日
yydsod  LV1 2022年6月5日
adminsean  LV13 2020年10月9日
bluewjg  LV3 2020年9月11日
Lp5080lp  LV9 2020年6月17日
林小小小小  LV1 2020年5月13日
t2tfeiyu  LV2 2020年1月18日
spring123spring  LV5 2019年12月1日
15838634741  LV18 2019年11月29日
xuyongff  LV24 2019年11月4日
最近浏览更多
akittyboy  LV9 2024年8月8日
edpwyg  LV14 2024年7月22日
EFWAGGFAWGR 2023年10月19日
暂无贡献等级
dzlwindy  LV8 2023年7月10日
taki5879  LV1 2023年1月2日
flygrass  LV12 2022年9月16日
tjtqyt  LV1 2022年6月26日
moomin709  LV24 2022年6月17日
yydsod  LV1 2022年6月5日
想个名熬一宿  LV2 2022年4月27日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友