|  |  |  | 
|---|
|  |  |  | package com.doumee.core.utils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.google.zxing.common.BitMatrix; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.apache.commons.fileupload.FileItem; | 
|---|
|  |  |  | import org.apache.commons.fileupload.FileItemFactory; | 
|---|
|  |  |  | import org.apache.commons.fileupload.disk.DiskFileItemFactory; | 
|---|
|  |  |  | 
|---|
|  |  |  | import java.math.RoundingMode; | 
|---|
|  |  |  | import java.net.URL; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | public class GeneratePicUtil { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | static String bg="https://shoeslxkj.oss-cn-beijing.aliyuncs.com/file/20230404/SysBaseBackGround/D56231512C0B4A4C9D06B02F9566B0B0.png"; | 
|---|
|  |  |  | 
|---|
|  |  |  | }return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | private static BufferedImage getImgIO(InputStream is) { | 
|---|
|  |  |  | if(is ==null){ | 
|---|
|  |  |  | log.error("=============================qrcode error 小程序码为空"); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | log.error("=============================qrcode okay 小程序码有有數據"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | return     ImageIO.read(is); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | log.error("=============================qrcode error 小程序码为空11111111111:"+e.getMessage()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | }return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static InputStream generateShareImg(String imgurl, InputStream mpCode, String title) { | 
|---|
|  |  |  | public static InputStream generateShareImg(String imgurl, InputStream mpCode1, String title) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BufferedImage bi =  new BufferedImage(750, 976, BufferedImage.TYPE_INT_RGB); | 
|---|
|  |  |  | //得到它的绘制环境(这张图片的笔) | 
|---|
|  |  |  | 
|---|
|  |  |  | g2.drawString("查看更多精彩内容", 40,820+th); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BufferedImage img3 = getImgIO(mpCode); | 
|---|
|  |  |  | BufferedImage img3 = getImgIO(mpCode1); | 
|---|
|  |  |  | if(img3!=null){ | 
|---|
|  |  |  | g2.setColor(Color.white); | 
|---|
|  |  |  | g2.drawImage(img3, 530, 736, 180, 180, null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | InputStream inputStream = bufferedImageToInputStream(bi); | 
|---|
|  |  |  | 
|---|
|  |  |  | g2.drawImage(setRadius(img1,img1.getWidth(),0,0), (int)(20*rate), (int)(h-68*rate), (int)(48*rate) ,(int)(48*rate), null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Font font =new Font("黑体", Font.PLAIN, (int)(28 * rate)); | 
|---|
|  |  |  | FontMetrics fontMetrics = g2.getFontMetrics(font); | 
|---|
|  |  |  | int textWidth = fontMetrics.stringWidth(name); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | g2.setColor(Color.white); | 
|---|
|  |  |  | g2.setFont(new Font("黑体", Font.PLAIN, (int)(28 * rate))); | 
|---|
|  |  |  | g2.drawString(name, (int) (80*rate),h-(int)((64-th)*rate)); | 
|---|
|  |  |  | Font font =new Font("黑体", Font.PLAIN, (int)(24 * rate)); | 
|---|
|  |  |  | g2.setColor(Color.white); | 
|---|
|  |  |  | g2.setFont(font); | 
|---|
|  |  |  | g2.drawString(name, (int) (80*rate),h-(int)((64-th)*rate)); | 
|---|
|  |  |  | g2.setColor(Color.white); | 
|---|
|  |  |  | g2.setFont(new Font("黑体", Font.PLAIN, (int)(24* rate))); | 
|---|
|  |  |  | g2.drawString("扫描看更多", (int)(w -(textWidth+30*rate)),h-(int)(rate*(50-th))); | 
|---|
|  |  |  | FontMetrics fontMetrics = g2.getFontMetrics(font); | 
|---|
|  |  |  | int textWidth = fontMetrics.stringWidth("扫码看更多"); | 
|---|
|  |  |  | g2.drawString("扫码看更多", (int)(w -(textWidth+20*rate)),h-(int)(rate*(50-th))); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BufferedImage img3 = getImgIO(mpCode); | 
|---|
|  |  |  | if(img3!=null){ | 
|---|