| | |
| | | private static BufferedImage getImgIO(InputStream is) { |
| | | if(is ==null){ |
| | | log.error("=============================qrcode error 小程序码为空"); |
| | | }else{ |
| | | |
| | | log.error("=============================qrcode okay 小程序码有有數據"); |
| | | } |
| | | try { |
| | | return ImageIO.read(is); |
| | |
| | | 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){ |