Commit cc9dff42 by 田超

modify playbutton

parent 53827730
......@@ -10,12 +10,15 @@ import org.slf4j.LoggerFactory;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.geom.RoundRectangle2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
/**
* @author TianChao
......@@ -28,9 +31,9 @@ public class PictureUtil {
private static Color defaultColor = new Color(252, 252, 252);
private static Color borderColor = new Color(221, 221, 221);
private static String playPic = "https://file.5rs.me/oss/uploadfe/png/800a688c0684efdcdf30053668ee7057.png";
private static String playPic = "https://file.5rs.me/oss/uploadfe/png/3c687bffac4d885ecfff8517d6c3f9c2.png";
private static String defaultBackgroundPic = "https://oss.5rs.me/oss/uploadfe/png/3003b8978e85052f96ababdf7d46f70a.png";
private static String borderPic = "C:\\Users\\LiHao\\Desktop\\封面图\\书本背景.png";
public static Color getImagePixel(String imgFile) {
BufferedImage bi = null;
......@@ -82,8 +85,10 @@ public class PictureUtil {
int backWidth = 702;
int backHeight = 299;
int splitPoint = 196;
int bookWidth = 172;
int bookHeight = 238;
int bookWidth = 157;
int bookHeight = 224;
int borderWidth = 185;
int borderHeight = 252;
int playButtonSize = 80;
//取书封面和播放按钮图
BufferedImage bookPicImage;
......@@ -119,7 +124,7 @@ public class PictureUtil {
os.close();
resultPath = uploadResultInfo == null ? null : uploadResultInfo.getUrl();
} catch (Exception e) {
LOGGER.error("生成合成图失败"+e.getMessage(),e);
LOGGER.error("生成合成图失败,url="+bookPic+"====="+e.getMessage(),e);
}
return resultPath;
......@@ -133,20 +138,26 @@ public class PictureUtil {
String playPic = "C:\\Users\\LiHao\\Desktop\\封面图\\播放按钮.png";
String defaultBackgroundPic = "C:\\Users\\LiHao\\Desktop\\封面图\\默认图背景.png";
String resultPath = "C:\\Users\\LiHao\\Desktop\\封面图\\result.jpg";
String oath = "C:\\Users\\LiHao\\Desktop\\封面图\\书本背景.png";
Boolean isDefalut = false;
try {
//取书封面和播放按钮图
BufferedImage bookPicImage;
BufferedImage playPicImage;
BufferedImage defaultBackgroudImage;
BufferedImage oathI;
if(bookPic.contains("https:")){
bookPicImage = ImageIO.read(new URL(bookPic));
playPicImage = ImageIO.read(new URL(playPic));
defaultBackgroudImage = ImageIO.read(new URL(defaultBackgroundPic));
oathI = ImageIO.read(new URL(oath));
}else{
bookPicImage = ImageIO.read(new File(bookPic));
playPicImage = ImageIO.read(new File(playPic));
defaultBackgroudImage = ImageIO.read(new File(defaultBackgroundPic));
oathI = ImageIO.read(new File(oath));
}
//画一个空的背景
......@@ -168,13 +179,31 @@ public class PictureUtil {
g.setColor(new Color(221, 221, 221));
//插入书籍图和播放按钮
g.drawImage(bookPicImage.getScaledInstance(172,238, Image.SCALE_DEFAULT), 265, 30, null);
g.drawImage(playPicImage.getScaledInstance(80,80, Image.SCALE_DEFAULT), 306, 105, null);
g.drawRect(265,30,172,238);
for(int i=0;i<3;i++){
}
// g.drawImage(oathI.getScaledInstance(185,252, Image.SCALE_DEFAULT), 258, 33, null);
BufferedImage image = new BufferedImage(157, 200, BufferedImage.TYPE_INT_ARGB);
Graphics2D gs = image.createGraphics();
Map mapH = new HashMap();
mapH.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //抗锯齿 (抗锯齿总开关)
mapH.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
gs.setRenderingHints(mapH);
// gs.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
gs.setClip(new RoundRectangle2D.Double(0, 0, 157, 224, 12, 12));
gs.drawImage(bookPicImage.getScaledInstance(157,224, Image.SCALE_DEFAULT), 0, 0, null);
g.drawImage(image.getScaledInstance(157,224, Image.SCALE_DEFAULT), 272, 38, null);
g.drawImage(playPicImage.getScaledInstance(80,80, Image.SCALE_DEFAULT), 306, 105, null);
// g.drawRect(265,30,172,238);
//保存图片
if(bookPic.contains("https:")) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment