Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
8bb0b506
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8bb0b506
编写于
11月 26, 2020
作者:
O
o2null
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
使用appche base64
上级
8abedf20
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
200 addition
and
196 deletion
+200
-196
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/personcard/CodeUtil.java
...anization/assemble/control/jaxrs/personcard/CodeUtil.java
+200
-196
未找到文件。
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/personcard/CodeUtil.java
浏览文件 @
8bb0b506
...
...
@@ -12,7 +12,8 @@ import java.util.Map;
import
java.util.Objects
;
import
javax.imageio.ImageIO
;
import
sun.misc.BASE64Decoder
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.zxing.BarcodeFormat
;
...
...
@@ -20,7 +21,6 @@ import com.google.zxing.EncodeHintType;
import
com.google.zxing.MultiFormatWriter
;
import
com.google.zxing.common.BitMatrix
;
public
class
CodeUtil
{
private
static
final
int
QRCOLOR
=
0xFF000000
;
// 默认是黑色
private
static
final
int
BGWHITE
=
0xFFFFFFFF
;
// 背景颜色
...
...
@@ -28,7 +28,8 @@ public class CodeUtil {
private
static
final
int
HEIGHT
=
300
;
// 二维码高
/**
*生成带logo的二维码图片
* 生成带logo的二维码图片
*
* @param logoFile /logo图片文件
* @param codeFile /二维码图片
* @param qrUrl /二维码存储的信息:vcard格式
...
...
@@ -85,7 +86,8 @@ public class CodeUtil {
outg2
.
drawImage
(
outImage
,
0
,
0
,
outImage
.
getWidth
(),
outImage
.
getHeight
(),
null
);
outg2
.
setColor
(
Color
.
BLACK
);
outg2
.
setFont
(
new
Font
(
"宋体"
,
Font
.
BOLD
,
30
));
// 字体、字型、字号
outg2
.
drawString
(
note2
,
200
-
strWidth2
/
2
,
outImage
.
getHeight
()
+
(
outImage2
.
getHeight
()
-
outImage
.
getHeight
())
/
2
+
5
);
outg2
.
drawString
(
note2
,
200
-
strWidth2
/
2
,
outImage
.
getHeight
()
+
(
outImage2
.
getHeight
()
-
outImage
.
getHeight
())
/
2
+
5
);
outg2
.
dispose
();
outImage2
.
flush
();
outImage
=
outImage2
;
...
...
@@ -109,13 +111,15 @@ public class CodeUtil {
}
/**
*生成带logo的二维码图片
* 生成带logo的二维码图片
*
* @param logoFile /logo图片文件
* @param codeFile /二维码图片
* @param qrUrl /二维码存储的信息:vcard格式
* @param note /二维码描述信息
*/
public
static
byte
[]
drawLogoQRCodeByte
(
BufferedImage
logo
,
ByteArrayOutputStream
codeFile
,
String
qrUrl
,
String
note
)
{
public
static
byte
[]
drawLogoQRCodeByte
(
BufferedImage
logo
,
ByteArrayOutputStream
codeFile
,
String
qrUrl
,
String
note
)
{
byte
[]
bs
=
null
;
try
{
MultiFormatWriter
multiFormatWriter
=
new
MultiFormatWriter
();
...
...
@@ -136,7 +140,7 @@ public class CodeUtil {
// 构建绘图对象
Graphics2D
g
=
image
.
createGraphics
();
// 读取Logo图片
//
BufferedImage logo = ImageIO.read(logoFile);
//
BufferedImage logo = ImageIO.read(logoFile);
// 开始绘制logo图片
g
.
drawImage
(
logo
,
width
*
2
/
5
,
height
*
2
/
5
,
width
*
2
/
10
,
height
*
2
/
10
,
null
);
g
.
dispose
();
...
...
@@ -167,7 +171,8 @@ public class CodeUtil {
outg2
.
drawImage
(
outImage
,
0
,
0
,
outImage
.
getWidth
(),
outImage
.
getHeight
(),
null
);
outg2
.
setColor
(
Color
.
BLACK
);
outg2
.
setFont
(
new
Font
(
"宋体"
,
Font
.
BOLD
,
30
));
// 字体、字型、字号
outg2
.
drawString
(
note2
,
200
-
strWidth2
/
2
,
outImage
.
getHeight
()
+
(
outImage2
.
getHeight
()
-
outImage
.
getHeight
())
/
2
+
5
);
outg2
.
drawString
(
note2
,
200
-
strWidth2
/
2
,
outImage
.
getHeight
()
+
(
outImage2
.
getHeight
()
-
outImage
.
getHeight
())
/
2
+
5
);
outg2
.
dispose
();
outImage2
.
flush
();
outImage
=
outImage2
;
...
...
@@ -193,7 +198,8 @@ public class CodeUtil {
private
static
Map
<
EncodeHintType
,
Object
>
hints
=
new
HashMap
<
EncodeHintType
,
Object
>()
{
private
static
final
long
serialVersionUID
=
1L
;
{
//put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);// 设置QR二维码的纠错级别(H为最高级别)具体级别信息
// put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);//
// 设置QR二维码的纠错级别(H为最高级别)具体级别信息
put
(
EncodeHintType
.
CHARACTER_SET
,
"utf-8"
);
// 设置编码方式
put
(
EncodeHintType
.
MARGIN
,
1
);
}
...
...
@@ -207,9 +213,7 @@ public class CodeUtil {
* @throws Exception
*/
public
static
File
decoderBase64File
(
String
targetPath
,
String
base64Code
)
throws
Exception
{
System
.
out
.
println
(
"base64Code="
+
base64Code
);
System
.
out
.
println
(
"targetPath="
+
targetPath
);
byte
[]
buffer
=
new
BASE64Decoder
().
decodeBuffer
(
base64Code
);
byte
[]
buffer
=
Base64
.
decodeBase64
(
base64Code
);
FileOutputStream
out
=
new
FileOutputStream
(
targetPath
);
out
.
write
(
buffer
);
out
.
close
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录