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
7f762b8f
Commit
7f762b8f
authored
Oct 22, 2018
by
songxiang
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
911a7f82
8b2c96aa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
28 deletions
+29
-28
PictureUtil.java
...on/src/main/java/com/pcloud/common/utils/PictureUtil.java
+29
-28
No files found.
pcloud-common/src/main/java/com/pcloud/common/utils/PictureUtil.java
View file @
7f762b8f
...
@@ -78,6 +78,25 @@ public class PictureUtil {
...
@@ -78,6 +78,25 @@ public class PictureUtil {
}
}
private
static
BufferedImage
subPic
(
BufferedImage
picImage
){
int
w
=
picImage
.
getWidth
();
int
h
=
picImage
.
getHeight
();
int
x1
=
w
,
y1
=
h
,
x2
=
0
,
y2
=
0
;
for
(
int
i
=
0
;
i
<
w
;
i
++){
for
(
int
j
=
0
;
j
<
h
;
j
++){
int
rgb
=
picImage
.
getRGB
(
i
,
j
);
if
(
rgb
!=
0
){
//不透明
if
(
i
<
x1
)
x1
=
i
;
if
(
j
<
y1
)
y1
=
j
;
if
(
i
>
x2
)
x2
=
i
;
if
(
j
>
y2
)
y2
=
j
;
}
}
}
return
picImage
.
getSubimage
(
x1
,
y1
,
x2
-
x1
+
1
,
y2
-
y1
+
1
);
}
public
static
String
getQrCover
(
String
bookPic
,
boolean
isDefault
){
public
static
String
getQrCover
(
String
bookPic
,
boolean
isDefault
){
String
resultPath
=
""
;
String
resultPath
=
""
;
...
@@ -103,6 +122,7 @@ public class PictureUtil {
...
@@ -103,6 +122,7 @@ public class PictureUtil {
g11
.
dispose
();
g11
.
dispose
();
bookPicImage
=
pic1
;
bookPicImage
=
pic1
;
}
}
bookPicImage
=
subPic
(
bookPicImage
);
playPicImage
=
ImageIO
.
read
(
new
URL
(
playPic
));
playPicImage
=
ImageIO
.
read
(
new
URL
(
playPic
));
defaultBackgroundImage
=
ImageIO
.
read
(
new
URL
(
defaultBackgroundPic
));
defaultBackgroundImage
=
ImageIO
.
read
(
new
URL
(
defaultBackgroundPic
));
...
@@ -143,7 +163,7 @@ public class PictureUtil {
...
@@ -143,7 +163,7 @@ public class PictureUtil {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
// String bookPic = "https://file.5rs.me/oss/upload/image/jpg/c2c7f0b85f9f4eb683cd86a2945bc5e5.jpg";
// String bookPic = "https://file.5rs.me/oss/upload/image/jpg/c2c7f0b85f9f4eb683cd86a2945bc5e5.jpg";
String
s
=
""
;
String
s
=
""
;
String
bookPic
=
"C:\\Users\\LiHao\\Desktop\\封面图\\
aa.jp
g"
;
String
bookPic
=
"C:\\Users\\LiHao\\Desktop\\封面图\\
yy.pn
g"
;
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"
;
...
@@ -161,12 +181,12 @@ public class PictureUtil {
...
@@ -161,12 +181,12 @@ public class PictureUtil {
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
));
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
));
oathI
=
ImageIO
.
read
(
new
File
(
oath
));
}
}
//画一个空的背景
//画一个空的背景
...
@@ -174,8 +194,7 @@ public class PictureUtil {
...
@@ -174,8 +194,7 @@ public class PictureUtil {
Graphics2D
g
=
bg
.
createGraphics
();
Graphics2D
g
=
bg
.
createGraphics
();
//获取主题色
//获取主题色
Color
c
=
getImagePixel
(
bookPic
);
Color
c
=
getImagePixel
(
bookPic
);
bookPicImage
=
subPic
(
bookPicImage
);
//画纯色的背景或者默认背景图
//画纯色的背景或者默认背景图
g
.
setColor
(
c
);
g
.
setColor
(
c
);
if
(
isDefalut
){
if
(
isDefalut
){
...
@@ -192,26 +211,9 @@ public class PictureUtil {
...
@@ -192,26 +211,9 @@ public class PictureUtil {
// g.drawImage(oathI.getScaledInstance(185,252, Image.SCALE_DEFAULT), 258, 33, null);
// g.drawImage(oathI.getScaledInstance(185,252, Image.SCALE_DEFAULT), 258, 33, null);
g
.
drawImage
(
bookPicImage
.
getScaledInstance
(
157
,
224
,
Image
.
SCALE_DEFAULT
),
265
,
30
,
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
.
drawImage
(
playPicImage
.
getScaledInstance
(
80
,
80
,
Image
.
SCALE_DEFAULT
),
306
,
105
,
null
);
//
g.drawRect(265,30,172,238);
g
.
drawRect
(
265
,
30
,
172
,
238
);
//保存图片
//保存图片
...
@@ -236,5 +238,4 @@ public class PictureUtil {
...
@@ -236,5 +238,4 @@ public class PictureUtil {
}
}
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