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

淘宝客网站制作视频教程免费网站建站平台

淘宝客网站制作视频教程,免费网站建站平台,uc浏览器官网,广西互联网营销公司2025年了,可能干不了几年了,还能写这种文章还是有点可笑。 背景 zxing库生成的二维码自带白边 分析 生产二维码主要分两步: 1.用QRCodeWriter生成BitMatrix信息 2.根据信息生成bitmap 问题在1。 生成二维码的尺寸实际是有一些规格的&a…

2025年了,可能干不了几年了,还能写这种文章还是有点可笑。

背景

zxing库生成的二维码自带白边

分析

生产二维码主要分两步:

1.用QRCodeWriter生成BitMatrix信息

2.根据信息生成bitmap

问题在1。

生成二维码的尺寸实际是有一些规格的,代码详细参见Encoder#encode,以下是具体规格:

确定输出变成的核心代码在QRCodeWriter#renderResult方法里,传入的边长和生成二维码的宽度可能不是倍数关系,比如传入边长15,但是二维码边长是7,那其实7*2=14就是最佳的最终二维码的边长了,剩余部分就是白边。知道了原因,解决方法如下,把输出尺寸变为二维码的倍数就好了。

解决

    private static BitMatrix renderResult(QRCode code, int width, int height, int quietZone) {ByteMatrix input = code.getMatrix();if (input == null) {throw new IllegalStateException();}int inputWidth = input.getWidth();int inputHeight = input.getHeight();int qrWidth = inputWidth + (quietZone * 2);int qrHeight = inputHeight + (quietZone * 2);int outputWidth = Math.max(width, qrWidth);int outputHeight = Math.max(height, qrHeight);int multiple = Math.min(outputWidth / qrWidth, outputHeight / qrHeight);// >> 去除白边 add by 某某outputWidth = qrWidth * multiple;outputHeight = qrHeight * multiple;// << 去除白边 add by 某某// Padding includes both the quiet zone and the extra white pixels to accommodate the requested// dimensions. For example, if input is 25x25 the QR will be 33x33 including the quiet zone.// If the requested size is 200x160, the multiple will be 4, for a QR of 132x132. These will// handle all the padding from 100x100 (the actual QR) up to 200x160.int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;int topPadding = (outputHeight - (inputHeight * multiple)) / 2;BitMatrix output = new BitMatrix(outputWidth, outputHeight);for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {// Write the contents of this row of the barcodefor (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {if (input.get(inputX, inputY) == 1) {output.setRegion(outputX, outputY, multiple, multiple);}}}return output;}

http://www.dtcms.com/wzjs/280412.html

相关文章:

  • 学会网站开发需要多久seo是什么味
  • 学做网站学费武汉竞价托管公司
  • 国外的有名的网站网址域名
  • 网页制作工具按其制作方式seo推广网络
  • 郑州专业网站推广公司宁波seo优化外包公司
  • 建设一个网站的费用百度6大核心部门
  • 网站底版照片怎么做seo外链是什么
  • 美国做色情网站犯法吗seo网站优化培训公司
  • iis 设置网站权限网站推广方法有哪些
  • 机械类 网站源码公司网站制作教程
  • 织梦pc怎么做手机网站东莞关键词优化平台
  • 关于重新建设网站的申请seo培训一对一
  • 阿拉丁做网站怎么做的在线培训平台
  • 如何使用模板网站建设网页正规推广赚佣金的平台
  • 长沙品牌网站建设河池网站seo
  • 工程建设监理学校网站网站推广四个阶段
  • 微网站建设的第一步是进行首页的设置一点优化
  • wordpress英文字体样式麒麟seo软件
  • 企业自助网站建设南京最大网站建设公司
  • 可以做网站吗何鹏seo
  • 怎么在百度做公司网站哪家建设公司网站
  • 店面转让找哪个网站做搜索引擎优化人员优化
  • 免费做网站的问题做个网页价格多少
  • 大连里程科技做网站谷歌seo怎么优化
  • php ajax网站开发典型实例网站制作免费
  • 政府找网站开发商要求百度推广首页
  • 英文集团网站设计建设网络广告文案案例
  • 农村自建房设计图120平方米三层百度关键词自然排名优化公司
  • 网上做网站兼职陕西网络营销优化公司
  • 网站开发网页超链接路径泉州百度广告