Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gk
Project
Project
Details
Activity
Releases
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
micro_app
gk
Commits
f5cd3cad
Commit
f5cd3cad
authored
Dec 28, 2023
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小程序二维码高清下载
parent
d8b90eac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
8 deletions
+27
-8
ResourcesController.java
...m/dlbridge/jadp/plugins/cmpt/web/ResourcesController.java
+27
-8
No files found.
src/main/java/com/dlbridge/jadp/plugins/cmpt/web/ResourcesController.java
View file @
f5cd3cad
...
@@ -84,20 +84,20 @@ public class ResourcesController {
...
@@ -84,20 +84,20 @@ public class ResourcesController {
response
.
addHeader
(
"Content-Disposition"
,
"attachment; filename=qrcode.jpg"
);
response
.
addHeader
(
"Content-Disposition"
,
"attachment; filename=qrcode.jpg"
);
JSONObject
obj
=
new
JSONObject
();
JSONObject
obj
=
new
JSONObject
();
obj
.
put
(
"scene"
,
"raceId="
+
cmptid
);
obj
.
put
(
"scene"
,
"raceId="
+
cmptid
);
obj
.
put
(
"width"
,
"1280"
);
String
partnerId
=
cmptService
.
getPartnerId
(
cmptid
);
String
partnerId
=
cmptService
.
getPartnerId
(
cmptid
);
// 重新获取小程序access_token
// 重新获取小程序access_token
String
accessToken
=
getMicroAccessToken
(
partnerId
);
String
accessToken
=
getMicroAccessToken
(
partnerId
);
ResponseEntity
<
org
.
springframework
.
core
.
io
.
Resource
>
resourceResponseEntity
=
restTemplate
.
postForEntity
(
ResponseEntity
<
org
.
springframework
.
core
.
io
.
Resource
>
resourceResponseEntity
=
restTemplate
.
postForEntity
(
"https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="
"https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="
+
accessToken
,
obj
.
toString
(),
org
.
springframework
.
core
.
io
.
Resource
.
class
);
+
accessToken
,
obj
.
toString
(),
org
.
springframework
.
core
.
io
.
Resource
.
class
);
Cmpt
cmpt
=
cmptService
.
queryCmptBycmptId
(
cmptid
);
Cmpt
cmpt
=
cmptService
.
queryCmptBycmptId
(
cmptid
);
if
(
resourceResponseEntity
.
getBody
().
getInputStream
()
!=
null
){
if
(
resourceResponseEntity
.
getBody
().
getInputStream
()
!=
null
){
BufferedImage
bg
=
ImageIO
.
read
(
resourceResponseEntity
.
getBody
().
getInputStream
());
BufferedImage
bg
=
ImageIO
.
read
(
resourceResponseEntity
.
getBody
().
getInputStream
());
BufferedImage
qr
=
ImageIO
.
read
(
new
URL
(
cmpt
.
getLogo
()));
BufferedImage
qr
=
ImageIO
.
read
(
new
URL
(
cmpt
.
getLogo
()));
overlapImage
(
bg
,
qr
,
response
);
overlapImage
HD
(
bg
,
qr
,
response
);
}
else
{
}
else
{
log
.
info
(
"=====获取小程序码为空:"
+
resourceResponseEntity
.
getBody
().
toString
());
log
.
info
(
"=====获取小程序码为空:"
+
resourceResponseEntity
.
getBody
().
toString
());
}
}
...
@@ -109,7 +109,7 @@ public class ResourcesController {
...
@@ -109,7 +109,7 @@ public class ResourcesController {
BufferedImage
background
=
resizeImage
(
300
,
300
,
bg
);
BufferedImage
background
=
resizeImage
(
300
,
300
,
bg
);
BufferedImage
qrCode
=
resizeImage
(
140
,
140
,
qrCodeIps
);
BufferedImage
qrCode
=
resizeImage
(
140
,
140
,
qrCodeIps
);
qrCode
=
converToRadius
(
qrCode
);
qrCode
=
converToRadius
(
qrCode
,
140
,
140
);
qrCode
.
createGraphics
().
setBackground
(
Color
.
WHITE
);
qrCode
.
createGraphics
().
setBackground
(
Color
.
WHITE
);
Graphics2D
g
=
background
.
createGraphics
();
Graphics2D
g
=
background
.
createGraphics
();
//在背景图片上添加二维码图片
//在背景图片上添加二维码图片
...
@@ -122,8 +122,27 @@ public class ResourcesController {
...
@@ -122,8 +122,27 @@ public class ResourcesController {
return
null
;
return
null
;
}
}
private
static
BufferedImage
converToRadius
(
BufferedImage
image
)
{
public
static
String
overlapImageHD
(
BufferedImage
bg
,
BufferedImage
qrCodeIps
,
HttpServletResponse
response
)
{
BufferedImage
output
=
new
BufferedImage
(
140
,
140
,
try
{
//设置图片大小
BufferedImage
background
=
resizeImage
(
1200
,
1200
,
bg
);
BufferedImage
qrCode
=
resizeImage
(
560
,
560
,
qrCodeIps
);
qrCode
=
converToRadius
(
qrCode
,
560
,
560
);
qrCode
.
createGraphics
().
setBackground
(
Color
.
WHITE
);
Graphics2D
g
=
background
.
createGraphics
();
//在背景图片上添加二维码图片
g
.
drawImage
(
qrCode
,
320
,
320
,
qrCode
.
getWidth
(),
qrCode
.
getHeight
(),
null
);
g
.
dispose
();
ImageIO
.
write
(
background
,
"jpg"
,
response
.
getOutputStream
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
private
static
BufferedImage
converToRadius
(
BufferedImage
image
,
int
width
,
int
height
)
{
BufferedImage
output
=
new
BufferedImage
(
width
,
height
,
BufferedImage
.
TYPE_INT_ARGB
);
BufferedImage
.
TYPE_INT_ARGB
);
Graphics2D
g2
=
output
.
createGraphics
();
Graphics2D
g2
=
output
.
createGraphics
();
...
@@ -131,8 +150,8 @@ public class ResourcesController {
...
@@ -131,8 +150,8 @@ public class ResourcesController {
g2
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
g2
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
RenderingHints
.
VALUE_ANTIALIAS_ON
);
RenderingHints
.
VALUE_ANTIALIAS_ON
);
g2
.
setColor
(
Color
.
WHITE
);
g2
.
setColor
(
Color
.
WHITE
);
g2
.
fill
(
new
RoundRectangle2D
.
Float
(
0
,
0
,
140
,
140
,
140
,
g2
.
fill
(
new
RoundRectangle2D
.
Float
(
0
,
0
,
width
,
height
,
width
,
140
));
height
));
g2
.
setComposite
(
AlphaComposite
.
SrcAtop
);
g2
.
setComposite
(
AlphaComposite
.
SrcAtop
);
g2
.
drawImage
(
image
,
0
,
0
,
null
);
g2
.
drawImage
(
image
,
0
,
0
,
null
);
...
...
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