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

济南市建设信用网站郑州网络推广代理

济南市建设信用网站,郑州网络推广代理,怎么做应用,怎么寻找要建设网站的客户群1.生成基础二维码 /*** 生成微信小程序二维码,带参数,最终转成base64* param page 当前小程序相对页面 必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不…

 1.生成基础二维码

    /*** 生成微信小程序二维码,带参数,最终转成base64* @param page 当前小程序相对页面 必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面* @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)* @param accessToken 接口调用凭证*/public static String generateQrCode(String page, String scene,String accessToken) {BufferedImage bi= null;try {URL url = new URL("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken);HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();httpURLConnection.setRequestMethod("POST");httpURLConnection.setDoOutput(true);httpURLConnection.setDoInput(true);PrintWriter printWriter = new PrintWriter(httpURLConnection.getOutputStream());JSONObject paramJson = new JSONObject();paramJson.put("scene", scene);paramJson.put("page", page);paramJson.put("width", 430);paramJson.put("auto_color", false);JSONObject lineColor = new JSONObject();lineColor.put("r", 0);lineColor.put("g", 0);lineColor.put("b", 0);paramJson.put("line_color", lineColor);printWriter.write(paramJson.toString());printWriter.flush();BufferedInputStream bis = new BufferedInputStream(httpURLConnection.getInputStream());bi = ImageIO.read(bis);printWriter.close();ByteArrayOutputStream stream = new ByteArrayOutputStream();try {// 设置图片格式ImageIO.write(bi, "jpg", stream);} catch (IOException e) {e.printStackTrace();}byte[] bytes = Base64.encodeBase64(stream.toByteArray());String base64 = new String(bytes);return "data:image/jpeg;base64," + base64;} catch (Exception e) {e.printStackTrace();}return null;}

2.自定义logo

加入以下代码:

            //要替换的图片路径BufferedImage logoImage = ImageIO.read(new URL("https://nk-mall.oss-cn-shenzhen.aliyuncs.com/WDMPV_MP/1698932836550.png"));// logo图的宽高int width = logoImage.getWidth();int height = logoImage.getHeight();// 保存正方形的边长int size = Math.min(width, height);// 判断那条边的边更长// 裁剪:获取正中间的正方形,边长为图片宽的值 后面.size方法必须调用 否则异常logoImage = Thumbnails.of(logoImage).sourceRegion(Positions.CENTER, size, size).size(size, size).asBufferedImage();// 转成圆形logoImage = convertCircular(logoImage);// 缩放:放大微信二维码的底图  目的为了减少对用户上传的图片缩放过小图片失真bi = Thumbnails.of(bi).size(bi.getHeight() * 2, bi.getHeight() * 2).asBufferedImage();// 使用Graphics2D合并图片Graphics2D g2 = null;// 读取微信二维码图片g2 = bi.createGraphics();// 合并:并设置偏移量,logo图片大小。具体需要自己按照实际的大小调整g2.drawImage(logoImage, 232 , 232, 395, 395, null);g2.dispose();

完整代码:

​
/*** 生成微信小程序二维码,带参数,最终转成base64* @param page 当前小程序相对页面 必须是已经发布的小程序存在的页面(否则报错),例如 pages/index/index, 根路径前不要填加 /,不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面* @param scene 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~,其它字符请自行编码为合法字符(因不支持%,中文无法使用 urlencode 处理,请使用其他编码方式)* @param accessToken 接口调用凭证*/public static String generateQrCode(String page, String scene,String accessToken) {BufferedImage bi= null;try {URL url = new URL("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken);HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();httpURLConnection.setRequestMethod("POST");httpURLConnection.setDoOutput(true);httpURLConnection.setDoInput(true);PrintWriter printWriter = new PrintWriter(httpURLConnection.getOutputStream());JSONObject paramJson = new JSONObject();paramJson.put("scene", scene);paramJson.put("page", page);paramJson.put("width", 430);paramJson.put("auto_color", false);JSONObject lineColor = new JSONObject();lineColor.put("r", 0);lineColor.put("g", 0);lineColor.put("b", 0);paramJson.put("line_color", lineColor);printWriter.write(paramJson.toString());printWriter.flush();BufferedInputStream bis = new BufferedInputStream(httpURLConnection.getInputStream());bi = ImageIO.read(bis);printWriter.close();//要替换的图片路径BufferedImage logoImage = ImageIO.read(new URL("https://nk-mall.oss-cn-shenzhen.aliyuncs.com/WDMPV_MP/1698932836550.png"));// logo图的宽高int width = logoImage.getWidth();int height = logoImage.getHeight();// 保存正方形的边长int size = Math.min(width, height);// 判断那条边的边更长// 裁剪:获取正中间的正方形,边长为图片宽的值 后面.size方法必须调用 否则异常logoImage = Thumbnails.of(logoImage).sourceRegion(Positions.CENTER, size, size).size(size, size).asBufferedImage();// 转成圆形logoImage = convertCircular(logoImage);// 缩放:放大微信二维码的底图  目的为了减少对用户上传的图片缩放过小图片失真bi = Thumbnails.of(bi).size(bi.getHeight() * 2, bi.getHeight() * 2).asBufferedImage();// 使用Graphics2D合并图片Graphics2D g2 = null;// 读取微信二维码图片g2 = bi.createGraphics();// 合并:并设置偏移量,logo图片大小。具体需要自己按照实际的大小调整g2.drawImage(logoImage, 232 , 232, 395, 395, null);g2.dispose();ByteArrayOutputStream stream = new ByteArrayOutputStream();try {// 设置图片格式ImageIO.write(bi, "jpg", stream);} catch (IOException e) {e.printStackTrace();}byte[] bytes = Base64.encodeBase64(stream.toByteArray());String base64 = new String(bytes);return "data:image/jpeg;base64," + base64;} catch (Exception e) {e.printStackTrace();}return null;}​

 

http://www.hkea.cn/news/82911/

相关文章:

  • 淄博企业网站建设有限公司搜索引擎关键词竞价排名
  • 网站的优点企业专业搜索引擎优化
  • 哪里有软件开发培训机构无锡seo培训
  • 网站怎么做反链seo是什么品牌
  • 技术型网站做哪一种好软文范例大全100
  • 百度搜索什么关键词能搜到网站seo高效优化
  • 网站搭建分站需要多少钱互联网营销策划
  • 音乐网站的音乐怎么做seo先上排名后收费
  • 清河做网站报价seo实战培训王乃用
  • wordpress 回收站在哪个文件夹营销方式和手段
  • 垂直型电商网站如何做快速排名软件哪个好
  • 做产品推广有网站比较好的免费自助建站平台
  • 番禺网站建设公司排名百度推广页面投放
  • 沈阳做微网站百度收录刷排名
  • 网站建设与管理技术发展seo是什么意思如何实现
  • 手机游戏开发制作公司最新seo视频教程
  • 网站优化过度被k长春seo排名公司
  • wordpress移除谷歌字体seo网站推广与优化方案
  • 十大景观设计公司排名seo权重查询
  • 水友做的yyf网站十大免费引流平台
  • 东莞公司网站制作百度识图网页版 在线
  • 企业级网站内容管理解决方案网站关键词快速排名服务
  • 影视采集网站怎么做收录关键词是网站seo的核心工作
  • 开发一个网站需要多少时间百度账号免费注册
  • 化妆品网站主页设计长沙关键词优化方法
  • 南阳建网站企业百度推广优化工具
  • 怎样把自己做的网页放在网站里如何做宣传推广营销
  • 七谷网络工作室重庆优化seo
  • 东莞网站建设规范软文内容
  • 项目网站建设业务分析搜索优化的培训免费咨询