当前位置: 首页 > news >正文

小微型企业网站建立网络公司门头

小微型企业网站建立,网络公司门头,怎么做可以聊天的网站,福泉网站制作Android生成二维码通常使用ZXing库#xff0c;其中提供了QRCodeWriter类。QRCodeWriter可将字符串编译为位矩阵BitMatrix#xff0c;然后我们可以将位矩阵转为Int数组#xff0c;通过bitmap.setPixels()方法将数组绘制于位图上。 1. 添加依赖 //Gradle Scripts - buil…Android生成二维码通常使用ZXing库其中提供了QRCodeWriter类。QRCodeWriter可将字符串编译为位矩阵BitMatrix然后我们可以将位矩阵转为Int数组通过bitmap.setPixels()方法将数组绘制于位图上。 1. 添加依赖 //Gradle Scripts - build.gradle(Module:app) implementation com.google.zxing:core:3.4.1 implementation com.journeyapps:zxing-android-embedded:4.2.0 2. 工具类 import android.graphics.Bitmap; import android.graphics.Color; import android.graphics.Matrix; import com.google.zxing.BarcodeFormat; import com.google.zxing.EncodeHintType; import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.qrcode.QRCodeWriter; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; import java.util.HashMap; import java.util.Map;public class QRCodeUtils {/*** 根据文本与容错值生成二维码位图* param text 文本* param errorCorrectionLevel 容错值* return 返回位图如无文本内容返回null*/public Bitmap getQRBitmap(String text, ErrorCorrectionLevel errorCorrectionLevel) {if(textnull){return null;}//错误值if(errorCorrectionLevelnull){errorCorrectionLevelErrorCorrectionLevel.H;}int width text.length() * 6; // 二维码图片的宽度if(errorCorrectionLevelErrorCorrectionLevel.L){width (int) (width*1.5);}else if(errorCorrectionLevelErrorCorrectionLevel.Q){width (int) (width*2);}else if(errorCorrectionLevelErrorCorrectionLevel.M){width (int) (width*3);}else if(errorCorrectionLevelErrorCorrectionLevel.H){width (int) (width*4);}int height width; // 二维码图片的高度int margin 1; // 二维码图片的空白边距MapEncodeHintType, Object hints new HashMap();hints.put(EncodeHintType.MARGIN, margin); // 设置空白边距hints.put(EncodeHintType.CHARACTER_SET, UTF-8); // 设置字符编码格式hints.put(EncodeHintType.ERROR_CORRECTION, errorCorrectionLevel); // 设置容错率try {// 根据配置参数生成位矩阵对象BitMatrix bitMatrix new QRCodeWriter().encode(text, BarcodeFormat.QR_CODE, width, height, hints);// 创建像素数组并根据位矩阵对象为数组元素赋色值int[] pixels new int[width * height];for (int y 0; y height; y) {for (int x 0; x width; x) {if (bitMatrix.get(x, y)) { // 返回true表示黑色色块pixels[y * width x] Color.BLACK;} else { // 返回false表示白色色块pixels[y * width x] Color.WHITE;}}}// 创建位图对象并根据像素数组设置每个像素的色值Bitmap bitmap Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);bitmap.setPixels(pixels, 0, width, 0, 0, width, height);//过小放大if(width500){float i500/width;Matrix matrixnew Matrix();matrix.setScale(i,i);bitmap Bitmap.createBitmap(bitmap,0,0,width,height,matrix,false);}return bitmap;} catch (WriterException e) {e.printStackTrace();return null;}} }3. 容错率 容错率即二维码允许损毁量。 ErrorCorrectionLevel.H 30% ErrorCorrectionLevel.M 25% ErrorCorrectionLevel.Q 15% ErrorCorrectionLevel.L 7%
http://www.pierceye.com/news/206161/

相关文章:

  • 企业网站管理系统多站多语言版电子书推送网站怎么做
  • 海洋公司做网站推广安阳网站如何做优化
  • 南昌网站开发公司哪家公司好网站建设接单
  • 宁波网站制作哪家强调用wordpress的文章编辑器
  • 在线制作手机网站公司网站建设厂家
  • 在线分析网站一个小外贸公司怎么开
  • 给自己的公司做网站怎么做好电脑手机一体网站
  • 精通网站建设 全能建站密码pdf电商网站设计理念
  • 百度推广建设网站是不是合发手机网站的必要性
  • 企业网站建设是什么实现的物质基础和技术支撑现货交易平台代理
  • 网站建设的描述长沙发布app
  • 好的设计作品网站代理网站建设
  • 做网站的软件m开头网站建设公司问候语
  • 做网站需要工商证吗app软件开发价格
  • 做足球原创短视频网站网站建设永远在路上
  • 做seo为什么要了解网站苏州做网站公司
  • 这几年做哪些网站能致富网站开发账务处理
  • 网站的版权信息做阿里巴巴网站卖货咋样
  • 找项目去哪个网站成都哪里有做网站的公司
  • 网站推广的方法及特点国外专门做童装的网站
  • 企业网站开发模型图wordpress 侧边导航
  • 济南网站系统优化网站建设属于什么专业
  • 114啦建站程序页面效果好的网站
  • 龙华网站建设-信科网络电子商务网站建设和技术现状
  • 网站备案有效期wordpress 评论图片
  • 搭建网站需要哪些步骤wordpress 主题使用
  • 网站怎么发布做微商天眼官方网站
  • qq群网站制作异常网站服务器失去响应
  • aspnet网站开发模板紫光华宇拼音输入法官方下载
  • 东莞网站设计价格wordpress的配置dns