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

中山做网站的大公司wordpress文章链接带问号

中山做网站的大公司,wordpress文章链接带问号,深圳坪山高级中学,兰州新区城乡建设局网站最近因个人需求需要对根据内容生成二维码和进行解析#xff01;记录一下#xff01;二维码其实就是一种编码技术#xff0c;只是这种编码技术是用在图片上了#xff0c;将给定的一些文字#xff0c;数字转换为一张经过特定编码的图片。这里利用的是 google 公司的 zxing使…最近因个人需求需要对根据内容生成二维码和进行解析记录一下二维码其实就是一种编码技术只是这种编码技术是用在图片上了将给定的一些文字数字转换为一张经过特定编码的图片。这里利用的是 google 公司的 zxing使用方便可以操作条形码或者二维码等 导入相关jar包: !-- 二维码 --dependencygroupIdcom.google.zxing/groupIdartifactIdcore/artifactIdversion3.3.0/version/dependencydependencygroupIdcom.google.zxing/groupIdartifactIdjavase/artifactIdversion3.3.3/version/dependency 二维码工具类编 创建二维码图片 public static BufferedImage createImage(String charSet, String content, int qrWidth, int qrHeight) {Hashtable hints new Hashtable();hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);hints.put(EncodeHintType.CHARACTER_SET, charSet);hints.put(EncodeHintType.MARGIN, 1);BitMatrix bitMatrix null;try {bitMatrix new MultiFormatWriter().encode(content, BarcodeFormat.QR_CODE, qrWidth, qrHeight, // 修改二维码底部高度hints);} catch (WriterException e) {e.printStackTrace();}int width bitMatrix.getWidth();int height bitMatrix.getHeight();BufferedImage image new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);for (int x 0; x width; x) {for (int y 0; y height; y) {image.setRGB(x, y, bitMatrix.get(x, y) ? 0xFF000000 : 0xFFFFFFFF);}}return image;} 二维码设置logo: public static void insertLogoImage(BufferedImage source, Image logo, int logoWidth, int logoHeight) {Graphics2D graph source.createGraphics();int qrWidth source.getWidth();int qrHeight source.getHeight();int x (qrWidth - logoWidth) / 2;int y (qrHeight - logoHeight) / 2;graph.drawImage(logo, x, y, logoWidth, logoHeight, null);Shape shape new RoundRectangle2D.Float(x, y, logoWidth, logoHeight, 6, 6);graph.setStroke(new BasicStroke(3f));graph.draw(shape);graph.dispose();} 将文明说明增加到二维码上: public static BufferedImage textToImage(String str, int width, int height, int fontSize) {BufferedImage textImage new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);Graphics2D g2 (Graphics2D) textImage.getGraphics();//开启文字抗锯齿g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);g2.setBackground(Color.WHITE);g2.clearRect(0, 0, width, height);g2.setPaint(Color.BLACK);FontRenderContext context g2.getFontRenderContext();Font font new Font(微软雅黑, Font.PLAIN, fontSize);g2.setFont(font);LineMetrics lineMetrics font.getLineMetrics(str, context);FontMetrics fontMetrics FontDesignMetrics.getMetrics(font);float offset (width - fontMetrics.stringWidth(str)) / 2;float y (height lineMetrics.getAscent() - lineMetrics.getDescent() - lineMetrics.getLeading()) / 2;g2.drawString(str, (int) offset, (int) y);return textImage;} 解析二维码 /** 解析二维码*/public static String decode(File file, DecodeHintType cherSet) throws Exception {BufferedImage image;image ImageIO.read(file);if (image null) {return null;}BufferedImageLuminanceSource source new BufferedImageLuminanceSource(image);BinaryBitmap bitmap new BinaryBitmap(new HybridBinarizer(source));Result result;Hashtable hints new Hashtable();hints.put(DecodeHintType.CHARACTER_SET, cherSet);hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);hints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE);result new MultiFormatReader().decode(bitmap, hints);String resultStr result.getText();return resultStr;} main方法测试类 public static void main(String[] args) {String content用户摄影作品版权信息;BufferedImage image QRCodeUtil.createImage( utf-8, content, 400, 400 );QRCodeUtil.addUpFont( image,用户摄影作品版权信息 );String formatNamepng;String imagePathD:\\temp\\java二维码.png;File filenew File(imagePath);try {ImageIO.write(image, formatName, file);} catch (IOException e) {e.printStackTrace();}String decode null;try {decode QRCodeUtil.decode(file, DecodeHintType.CHARACTER_SET);} catch (Exception e) {e.printStackTrace();}System.out.println(decode);System.out.println(执行完成);} 这样就实现了 二维码里面的内容根据实际数据来就行用手机扫描后查看。
http://www.pierceye.com/news/908622/

相关文章:

  • 中国空间站网站色彩的应用
  • 网站分为哪些部分组成部分wordpress 用户密码加密方式
  • 产品展示栏目在网站中的作用电子商务网站建设实训方案
  • 做外贸网站需要请外贸文员吗pc端设计网站
  • 免费按模板制作微网站厦门十大软件公司
  • 免费网站模板在哪下载什么网站做的最好
  • 在智联招聘网站做销售医疗软件网站建设公司排名
  • 小程序商城设计太原搜索引擎优化
  • 旅游商业网站策划书网页在线设计平台
  • 网站建设的软文怎么写深圳我的网站
  • 动漫网站建设意义js 取网站域名
  • 网站建设项目功能需求分析报告做健身类小程序的网站
  • 专业建设网站公司哪家好建设工程合同管理多少分及格
  • 网站制作是那个大连开发区一中
  • 做预约的网站2345网址导航官网下载
  • 网站建设创建wordpress用户评论图片
  • .耐思尼克官方网站工程公司会计账务处理
  • 如何进入微网站毕业设计网站开发
  • 已经备案的网站新增ip怎么做网站分站如何做
  • 网站建设 常州怎么做网络推广营销
  • 海南建设工程信息网站常用网站建设软件
  • 福州网络推广建站网站建设工作室深圳
  • html的网站案例长春头条新闻今天
  • 免费的十大免费货源网站产品设计开发流程图
  • 做网站的内容网站建设工作室有几个部门
  • jquery win8风格企业网站模板wordpress编辑器 模板
  • 北京国互网网站建设电话免费网站怎么盈利模式
  • 网站建设图片如何加载ssh做电商 网站
  • 网站开发资质网站域名服务错误
  • html5 社团网站模板 代码下载上海做营销网站哪个公司好