Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
徐少华
midjourney-proxy
Commits
cc9dff42
Commit
cc9dff42
authored
Oct 15, 2018
by
田超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify playbutton
parent
53827730
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
10 deletions
+39
-10
PictureUtil.java
...on/src/main/java/com/pcloud/common/utils/PictureUtil.java
+39
-10
No files found.
pcloud-common/src/main/java/com/pcloud/common/utils/PictureUtil.java
View file @
cc9dff42
...
@@ -10,12 +10,15 @@ import org.slf4j.LoggerFactory;
...
@@ -10,12 +10,15 @@ import org.slf4j.LoggerFactory;
import
javax.imageio.ImageIO
;
import
javax.imageio.ImageIO
;
import
java.awt.*
;
import
java.awt.*
;
import
java.awt.geom.RoundRectangle2D
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayOutputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.FileOutputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStream
;
import
java.net.URL
;
import
java.net.URL
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
/**
* @author TianChao
* @author TianChao
...
@@ -28,9 +31,9 @@ public class PictureUtil {
...
@@ -28,9 +31,9 @@ public class PictureUtil {
private
static
Color
defaultColor
=
new
Color
(
252
,
252
,
252
);
private
static
Color
defaultColor
=
new
Color
(
252
,
252
,
252
);
private
static
Color
borderColor
=
new
Color
(
221
,
221
,
221
);
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
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
)
{
public
static
Color
getImagePixel
(
String
imgFile
)
{
BufferedImage
bi
=
null
;
BufferedImage
bi
=
null
;
...
@@ -82,8 +85,10 @@ public class PictureUtil {
...
@@ -82,8 +85,10 @@ public class PictureUtil {
int
backWidth
=
702
;
int
backWidth
=
702
;
int
backHeight
=
299
;
int
backHeight
=
299
;
int
splitPoint
=
196
;
int
splitPoint
=
196
;
int
bookWidth
=
172
;
int
bookWidth
=
157
;
int
bookHeight
=
238
;
int
bookHeight
=
224
;
int
borderWidth
=
185
;
int
borderHeight
=
252
;
int
playButtonSize
=
80
;
int
playButtonSize
=
80
;
//取书封面和播放按钮图
//取书封面和播放按钮图
BufferedImage
bookPicImage
;
BufferedImage
bookPicImage
;
...
@@ -119,7 +124,7 @@ public class PictureUtil {
...
@@ -119,7 +124,7 @@ public class PictureUtil {
os
.
close
();
os
.
close
();
resultPath
=
uploadResultInfo
==
null
?
null
:
uploadResultInfo
.
getUrl
();
resultPath
=
uploadResultInfo
==
null
?
null
:
uploadResultInfo
.
getUrl
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"生成合成图失败"
+
e
.
getMessage
(),
e
);
LOGGER
.
error
(
"生成合成图失败
,url="
+
bookPic
+
"=====
"
+
e
.
getMessage
(),
e
);
}
}
return
resultPath
;
return
resultPath
;
...
@@ -133,20 +138,26 @@ public class PictureUtil {
...
@@ -133,20 +138,26 @@ public class PictureUtil {
String
playPic
=
"C:\\Users\\LiHao\\Desktop\\封面图\\播放按钮.png"
;
String
playPic
=
"C:\\Users\\LiHao\\Desktop\\封面图\\播放按钮.png"
;
String
defaultBackgroundPic
=
"C:\\Users\\LiHao\\Desktop\\封面图\\默认图背景.png"
;
String
defaultBackgroundPic
=
"C:\\Users\\LiHao\\Desktop\\封面图\\默认图背景.png"
;
String
resultPath
=
"C:\\Users\\LiHao\\Desktop\\封面图\\result.jpg"
;
String
resultPath
=
"C:\\Users\\LiHao\\Desktop\\封面图\\result.jpg"
;
String
oath
=
"C:\\Users\\LiHao\\Desktop\\封面图\\书本背景.png"
;
Boolean
isDefalut
=
false
;
Boolean
isDefalut
=
false
;
try
{
try
{
//取书封面和播放按钮图
//取书封面和播放按钮图
BufferedImage
bookPicImage
;
BufferedImage
bookPicImage
;
BufferedImage
playPicImage
;
BufferedImage
playPicImage
;
BufferedImage
defaultBackgroudImage
;
BufferedImage
defaultBackgroudImage
;
BufferedImage
oathI
;
if
(
bookPic
.
contains
(
"https:"
)){
if
(
bookPic
.
contains
(
"https:"
)){
bookPicImage
=
ImageIO
.
read
(
new
URL
(
bookPic
));
bookPicImage
=
ImageIO
.
read
(
new
URL
(
bookPic
));
playPicImage
=
ImageIO
.
read
(
new
URL
(
playPic
));
playPicImage
=
ImageIO
.
read
(
new
URL
(
playPic
));
defaultBackgroudImage
=
ImageIO
.
read
(
new
URL
(
defaultBackgroundPic
));
defaultBackgroudImage
=
ImageIO
.
read
(
new
URL
(
defaultBackgroundPic
));
oathI
=
ImageIO
.
read
(
new
URL
(
oath
));
}
else
{
}
else
{
bookPicImage
=
ImageIO
.
read
(
new
File
(
bookPic
));
bookPicImage
=
ImageIO
.
read
(
new
File
(
bookPic
));
playPicImage
=
ImageIO
.
read
(
new
File
(
playPic
));
playPicImage
=
ImageIO
.
read
(
new
File
(
playPic
));
defaultBackgroudImage
=
ImageIO
.
read
(
new
File
(
defaultBackgroundPic
));
defaultBackgroudImage
=
ImageIO
.
read
(
new
File
(
defaultBackgroundPic
));
oathI
=
ImageIO
.
read
(
new
File
(
oath
));
}
}
//画一个空的背景
//画一个空的背景
...
@@ -168,13 +179,31 @@ public class PictureUtil {
...
@@ -168,13 +179,31 @@ public class PictureUtil {
g
.
setColor
(
new
Color
(
221
,
221
,
221
));
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:"
))
{
if
(
bookPic
.
contains
(
"https:"
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment