阅读背景:

二维码扫描效果

来源:互联网 

生成二维码的两种效果,第一种没有白色背景

/** * 生成二维码图片方法 * */ public Bitmap Create2DCode(String str) throws WriterException { BitMatrix matrix = new MultiFormatWriter().encode(str,BarcodeFormat.QR_CODE, 320,320); int width = matrix.getWidth(); int height = matrix.getHeight(); int[] pixels = new int[width * height]; for (int y = 0; y < height; y++) { for(int x = 0; x < width; x++){ if(matrix.get(x, y)){ pixels[y * width + x] = 0xff000000; } } } Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); bitmap.setPixels(pixels, 0, width, 0, 0, width, height); return bitmap; } /** * 生成二维码图片方法 * */ public B


你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: