Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
soss
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
hooloo
ms
soss
Commits
7e120bd0
Commit
7e120bd0
authored
Feb 24, 2023
by
caiyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改二维码尺寸生成逻辑
parent
af4d8834
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
soss-common/src/main/java/com/soss/common/utils/QRCodeUtil.java
+7
-2
No files found.
soss-common/src/main/java/com/soss/common/utils/QRCodeUtil.java
View file @
7e120bd0
...
...
@@ -17,7 +17,7 @@ import java.util.Hashtable;
public
class
QRCodeUtil
{
private
static
int
onColor
=
0xFF000000
;
//前景色
private
static
int
offColor
=
0xFFFFFFFF
;
//背景色
private
static
int
margin
=
1
;
//白边大小,取值范围0~4
private
static
int
margin
=
0
;
//白边大小,取值范围0~4
private
static
ErrorCorrectionLevel
level
=
ErrorCorrectionLevel
.
L
;
//二维码容错率
/**
...
...
@@ -34,15 +34,20 @@ public class QRCodeUtil {
hints
.
put
(
EncodeHintType
.
MARGIN
,
margin
);
//设置白边
try
{
BitMatrix
bitMatrix
=
new
MultiFormatWriter
().
encode
(
content
,
BarcodeFormat
.
QR_CODE
,
width
,
height
,
hints
);
bitMatrix
=
deleteWhite
(
bitMatrix
);
//
bitMatrix = deleteWhite(bitMatrix);
BufferedImage
image
=
toBufferedImage
(
bitMatrix
);
// MatrixToImageWriter.writeToStream(bitMatrix, format, byteArrayOutputStream, config);
ImageIO
.
write
(
image
,
format
,
byteArrayOutputStream
);
//生成二维码图片
// ImageIO.write(image, format, new File("C:\\Users\\caiyo\\Desktop\\test.png")); //生成二维码图片
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
static
void
main
(
String
[]
args
)
{
generateQRImage
(
"test"
,
"PNG"
,
null
,
151
,
151
);
}
/**
* @param matrix 二维码矩阵相关
* @param format 二维码图片格式
...
...
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