下载此文档

Java使用Zxing包制作二维码.doc


文档分类:IT计算机 | 页数:约22页 举报非法文档有奖
1/22
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/22 下载此文档
文档列表 文档介绍
域名长度后缀删除日期删除类型 2012/9/4 Delete 今天朋友问我一个二维码的东西,说实话我重来也没接触过,于是上网找了一下,和朋友分享一下... 用 r 也能做, 但是一看小日本的, 于是马上闪过,听所 zxin g 挺好用的,于是就去 google 下了架包用了这个感觉确实简单,重百度找到写完一个例子只用了, 10 来分钟........ //ng 是 Google 提供的关于条码(一维码、二维码)的解析工具, 提供了二维码的生成与解析的方法,现在我简单介绍一下使用 Jav a 利用 Zxing 生成与解析二维码 1 、二维码的生成 将 包加入到 classpath 下。 二维码的生成需要借助 MatrixToImageWriter 类,该类是由 Google 提供的,可以将该类拷贝到源码中,这里我将该类的源码贴上,可以直接使用。[java] view plaincopyprint?.; import ; import ; import ; import ; import ; public final class MatrixToImageWriter { private static final int BLACK = 0xFF000000; private static final int WHITE = 0xFFFFFFFF; private MatrixToImageWriter() {} public static BufferedImage toBufferedImage(BitMatrix matrix) { int width = (); int height = (); BufferedImage image = new BufferedImage(width, height, ); for (int x= 0;x< width; x++) { for (int y= 0;y< height; y++) { (x, y, (x, y)? BLACK : WHITE); }} return image; } public static void writeToFile(BitMatrix matrix, String format, File file) throws IOException { BufferedImage image = toBufferedImage(matrix); if (!(image, format, file)) { throw new IOException("Could not write an image of format "+ format +" to"+ file); }} public static void writeToStream(BitMatrix matrix, String format, OutputStream stream) throws IOException { BufferedImage image = toBufferedImage(matrix); if (!(image, format, stream)) { throw new IOException("Could not write an image of format "+ format); }}} .; import ; import ; import ; import ; import ; public final class MatrixToImageWriter { private static final int BLACK = 0xFF000000; private static final int WHITE = 0xFFFFFFFF; private MatrixToImageWriter() {} public stati

Java使用Zxing包制作二维码 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数22
  • 收藏数0 收藏
  • 顶次数0
  • 上传人yzhluyin1
  • 文件大小0 KB
  • 时间2016-06-30