Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
GeneralClassLibrary
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 9b0cfda5
由
LN
编写于
2019-07-31 16:56:50 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
437486c7
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
230 行增加
和
66 行删除
CodeLibraryProject/CodeLibrary/FrmCodeDecode.Designer.cs
CodeLibraryProject/CodeLibrary/FrmCodeDecode.cs
CodeLibraryProject/CodeLibrary/FrmCodeLearn.cs
CodeLibraryProject/CodeLibrary/ZXingCodeHelper.cs
CodeLibraryProject/CodeTest/CodeCreater.cs
CodeLibraryProject/CodeTest/Program.cs
CodeLibraryProject/dll/CodeLibrary.dll
CodeLibraryProject/编译好的DLL/CodeLibrary.dll
CodeLibraryProject/CodeLibrary/FrmCodeDecode.Designer.cs
查看文件 @
9b0cfda
...
...
@@ -55,6 +55,7 @@
this
.
label4
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
btnLight
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
button1
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
chbZxing
=
new
System
.
Windows
.
Forms
.
CheckBox
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox1
)).
BeginInit
();
this
.
SuspendLayout
();
//
...
...
@@ -101,7 +102,7 @@
// btnErZhi
//
this
.
btnErZhi
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnErZhi
.
Location
=
new
System
.
Drawing
.
Point
(
557
,
12
);
this
.
btnErZhi
.
Location
=
new
System
.
Drawing
.
Point
(
768
,
478
);
this
.
btnErZhi
.
Name
=
"btnErZhi"
;
this
.
btnErZhi
.
Size
=
new
System
.
Drawing
.
Size
(
59
,
33
);
this
.
btnErZhi
.
TabIndex
=
5
;
...
...
@@ -113,7 +114,7 @@
// btnGray
//
this
.
btnGray
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnGray
.
Location
=
new
System
.
Drawing
.
Point
(
557
,
50
);
this
.
btnGray
.
Location
=
new
System
.
Drawing
.
Point
(
768
,
439
);
this
.
btnGray
.
Name
=
"btnGray"
;
this
.
btnGray
.
Size
=
new
System
.
Drawing
.
Size
(
59
,
33
);
this
.
btnGray
.
TabIndex
=
6
;
...
...
@@ -173,7 +174,7 @@
// btnClearLog
//
this
.
btnClearLog
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnClearLog
.
Location
=
new
System
.
Drawing
.
Point
(
71
1
,
50
);
this
.
btnClearLog
.
Location
=
new
System
.
Drawing
.
Point
(
69
1
,
50
);
this
.
btnClearLog
.
Name
=
"btnClearLog"
;
this
.
btnClearLog
.
Size
=
new
System
.
Drawing
.
Size
(
116
,
33
);
this
.
btnClearLog
.
TabIndex
=
12
;
...
...
@@ -301,7 +302,7 @@
// btnAn
//
this
.
btnAn
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnAn
.
Location
=
new
System
.
Drawing
.
Point
(
645
,
50
);
this
.
btnAn
.
Location
=
new
System
.
Drawing
.
Point
(
768
,
555
);
this
.
btnAn
.
Name
=
"btnAn"
;
this
.
btnAn
.
Size
=
new
System
.
Drawing
.
Size
(
59
,
33
);
this
.
btnAn
.
TabIndex
=
25
;
...
...
@@ -316,7 +317,7 @@
this
.
chbUseParam
.
Checked
=
true
;
this
.
chbUseParam
.
CheckState
=
System
.
Windows
.
Forms
.
CheckState
.
Checked
;
this
.
chbUseParam
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
chbUseParam
.
Location
=
new
System
.
Drawing
.
Point
(
71
1
,
18
);
this
.
chbUseParam
.
Location
=
new
System
.
Drawing
.
Point
(
69
1
,
18
);
this
.
chbUseParam
.
Name
=
"chbUseParam"
;
this
.
chbUseParam
.
Size
=
new
System
.
Drawing
.
Size
(
75
,
21
);
this
.
chbUseParam
.
TabIndex
=
26
;
...
...
@@ -346,7 +347,7 @@
// btnLight
//
this
.
btnLight
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnLight
.
Location
=
new
System
.
Drawing
.
Point
(
645
,
12
);
this
.
btnLight
.
Location
=
new
System
.
Drawing
.
Point
(
768
,
517
);
this
.
btnLight
.
Name
=
"btnLight"
;
this
.
btnLight
.
Size
=
new
System
.
Drawing
.
Size
(
59
,
33
);
this
.
btnLight
.
TabIndex
=
24
;
...
...
@@ -358,7 +359,7 @@
// button1
//
this
.
button1
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
button1
.
Location
=
new
System
.
Drawing
.
Point
(
723
,
12
);
this
.
button1
.
Location
=
new
System
.
Drawing
.
Point
(
833
,
555
);
this
.
button1
.
Name
=
"button1"
;
this
.
button1
.
Size
=
new
System
.
Drawing
.
Size
(
167
,
33
);
this
.
button1
.
TabIndex
=
29
;
...
...
@@ -367,11 +368,23 @@
this
.
button1
.
Visible
=
false
;
this
.
button1
.
Click
+=
new
System
.
EventHandler
(
this
.
button1_Click
);
//
// chbZxing
//
this
.
chbZxing
.
AutoSize
=
true
;
this
.
chbZxing
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
chbZxing
.
Location
=
new
System
.
Drawing
.
Point
(
781
,
18
);
this
.
chbZxing
.
Name
=
"chbZxing"
;
this
.
chbZxing
.
Size
=
new
System
.
Drawing
.
Size
(
60
,
21
);
this
.
chbZxing
.
TabIndex
=
30
;
this
.
chbZxing
.
Text
=
"ZXing"
;
this
.
chbZxing
.
UseVisualStyleBackColor
=
true
;
//
// FrmCodeDecode
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1192
,
729
);
this
.
Controls
.
Add
(
this
.
chbZxing
);
this
.
Controls
.
Add
(
this
.
button1
);
this
.
Controls
.
Add
(
this
.
txtParamPath
);
this
.
Controls
.
Add
(
this
.
label4
);
...
...
@@ -438,6 +451,7 @@
private
System
.
Windows
.
Forms
.
Label
label4
;
private
System
.
Windows
.
Forms
.
Button
btnLight
;
private
System
.
Windows
.
Forms
.
Button
button1
;
private
System
.
Windows
.
Forms
.
CheckBox
chbZxing
;
}
}
CodeLibraryProject/CodeLibrary/FrmCodeDecode.cs
查看文件 @
9b0cfda
...
...
@@ -80,7 +80,8 @@ namespace CodeLibrary
{
System
.
Windows
.
Forms
.
OpenFileDialog
openDialog
=
new
System
.
Windows
.
Forms
.
OpenFileDialog
();
openDialog
.
Title
=
selImage
;
openDialog
.
Filter
=
"(*.jpg)|*.jpg|(*.png)|*.png|(*.bmp)|*.bmp"
;
openDialog
.
Filter
=
"(*.jpg;*.png;*.bmp)|*.jpg;*.png;*.bmp"
;
// openDialog.Filter = "All Supported Images (*.bmp;*.dib;*.rle;*.gif;*.jpg;*.png)|*.bmp;*.dib;*.rle;*.gif;*.jpg;*.png|Bitmaps (*.bmp;*.dib;*.rle)|*.bmp;*.dib;*.rle|Graphics Interchange Format (*.gif)|*.gif|Joint Photographic Experts (*.jpg)|*.jpg|Portable Network Graphics (*.png)|*.png|All Files (*.*)|*.*";
//openDialog.DefaultExt = "png";
System
.
Windows
.
Forms
.
DialogResult
result
=
openDialog
.
ShowDialog
();
if
(
result
==
System
.
Windows
.
Forms
.
DialogResult
.
Cancel
)
...
...
@@ -151,9 +152,16 @@ namespace CodeLibrary
stopwatch
.
Restart
();
HDCodeHelper
.
HalconWindow
=
this
.
hWindowControl1
.
HalconWindow
;
Bitmap
map
=
new
Bitmap
(
pictureBox1
.
Image
);
List
<
CodeInfo
>
result
=
HDCodeHelper
.
DecodeBarCode
(
map
);
ShowCode
(
result
);
txtResult
.
Text
+=
"\r\n elapsed time:"
+
stopwatch
.
Elapsed
.
ToString
();
if
(
chbZxing
.
Checked
)
{
zxingDecode
(
map
,
"barcode"
);
}
else
{
List
<
CodeInfo
>
result
=
HDCodeHelper
.
DecodeBarCode
(
map
);
ShowCode
(
result
);
txtResult
.
Text
+=
"\r\n elapsed time:"
+
stopwatch
.
Elapsed
.
ToString
();
}
}
public
void
ShowImage
(
HObject
ho_Image
)
{
...
...
@@ -196,32 +204,45 @@ namespace CodeLibrary
{
codeParamPath
=
""
;
}
List
<
CodeInfo
>
codeList
=
new
List
<
CodeInfo
>();
if
(
cmbCodeType
.
Text
.
ToLower
().
Equals
(
"barcode"
))
{
codeList
=
HDCodeHelper
.
DecodeBarCode
(
ho_image
);
if
(
chbZxing
.
Checked
)
{
zxingDecode
(
map
,
cmbCodeType
.
Text
);
}
else
{
codeList
=
HDCodeHelper
.
DecodeCode
(
ho_image
,
count
,
codeParamPath
,
cmbCodeType
.
Text
);
}
List
<
CodeInfo
>
codeList
=
new
List
<
CodeInfo
>();
if
(
cmbCodeType
.
Text
.
ToLower
().
Equals
(
"barcode"
))
{
codeList
=
HDCodeHelper
.
DecodeBarCode
(
ho_image
);
}
else
{
codeList
=
HDCodeHelper
.
DecodeCode
(
ho_image
,
count
,
codeParamPath
,
cmbCodeType
.
Text
);
}
if
(
codeList
.
Count
<=
0
)
{
string
result
=
ZXingCodeHelper
.
DecodeQRCode
(
map
);
if
(!
String
.
IsNullOrEmpty
(
result
))
if
(
codeList
.
Count
<=
0
)
{
txtResult
.
Text
=
" zxing decode:\r\n"
+
result
;
zxingDecode
(
map
,
cmbCodeType
.
Text
);
}
else
{
ShowCode
(
codeList
);
txtResult
.
Text
+=
"\r\n elapsed time:"
+
stopwatch
.
Elapsed
.
ToString
();
}
}
else
}
private
void
zxingDecode
(
Bitmap
map
,
string
type
)
{
List
<
string
>
results
=
ZXingCodeHelper
.
DeCodes
(
map
,
type
);
txtResult
.
Text
=
" zxing decode:"
;
foreach
(
string
code
in
results
)
{
ShowCode
(
codeList
);
txtResult
.
Text
+=
"\r\n elapsed time:"
+
stopwatch
.
Elapsed
.
ToString
();
txtResult
.
Text
+=
"\r\n"
+
"\r\n"
+
code
;
}
}
txtResult
.
Text
+=
"\r\n \r\n elapsed time:"
+
stopwatch
.
Elapsed
.
ToString
();
}
private
void
btnClearLog_Click
(
object
sender
,
EventArgs
e
)
{
HDLogUtil
.
ClearLog
();
...
...
CodeLibraryProject/CodeLibrary/FrmCodeLearn.cs
查看文件 @
9b0cfda
...
...
@@ -227,7 +227,7 @@ namespace CodeLibrary
{
System
.
Windows
.
Forms
.
OpenFileDialog
openDialog
=
new
System
.
Windows
.
Forms
.
OpenFileDialog
();
openDialog
.
Title
=
selImage
;
openDialog
.
Filter
=
"(*.jpg
)|*.jpg|(*.png)|*.png|(*.bmp)|
*.bmp"
;
openDialog
.
Filter
=
"(*.jpg
;*.png;*.bmp)|*.jpg;*.png;
*.bmp"
;
//openDialog.DefaultExt = "png";
System
.
Windows
.
Forms
.
DialogResult
result
=
openDialog
.
ShowDialog
();
if
(
result
==
System
.
Windows
.
Forms
.
DialogResult
.
Cancel
)
...
...
CodeLibraryProject/CodeLibrary/ZXingCodeHelper.cs
查看文件 @
9b0cfda
...
...
@@ -6,37 +6,161 @@ using System.Text;
using
System.Threading.Tasks
;
using
ZXing
;
using
ZXing.Common
;
using
ZXing.Multi.QrCode
;
namespace
CodeLibrary
{
public
class
ZXingCodeHelper
{
public
static
string
DecodeQRCode
(
Bitmap
bmp
)
public
static
List
<
string
>
DeCodes
(
Bitmap
map
,
string
codeType
)
{
string
text
=
""
;
DecodingOptions
option
=
new
DecodingOptions
();
if
(
codeType
.
ToUpper
().
Equals
(
"QR CODE"
))
{
return
DecodeQRCodes
(
map
);
}
else
if
(
codeType
.
ToUpper
().
Equals
(
"DATA MATRIX ECC 200"
))
{
return
DecodeCodes
(
map
);
}
else
if
(
codeType
.
ToUpper
().
Equals
(
"BARCODE"
))
{
return
DecodeCodes
(
map
);
}
else
{
return
DecodeCodes
(
map
);
}
//option.PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.QR_CODE, BarcodeFormat.All_1D };
option
.
PossibleFormats
=
new
List
<
BarcodeFormat
>()
{
BarcodeFormat
.
QR_CODE
};
BarcodeReader
br
=
new
BarcodeReader
();
}
public
static
List
<
string
>
DecodeCodes
(
Bitmap
bmp
)
{
MultiFormatReader
mreader
=
new
MultiFormatReader
();
ZXing
.
Multi
.
GenericMultipleBarcodeReader
genericMultiple
=
new
ZXing
.
Multi
.
GenericMultipleBarcodeReader
(
mreader
);
LuminanceSource
source
=
new
BitmapLuminanceSource
(
bmp
);
BinaryBitmap
binarybitmap
=
new
BinaryBitmap
(
new
HybridBinarizer
(
source
));
Result
[]
rr
=
genericMultiple
.
decodeMultiple
(
binarybitmap
);
List
<
string
>
result
=
new
List
<
string
>();
if
(
rr
!=
null
)
{
foreach
(
Result
res
in
rr
)
{
if
(
res
!=
null
)
{
string
text
=
res
.
ToString
();
br
.
Options
=
option
;
Result
rs
=
br
.
Decode
(
bmp
);
if
(!
IsGBCode
(
text
))
{
text
=
ConvertISO88591ToEncoding
(
text
,
Encoding
.
Default
);
}
result
.
Add
(
text
);
}
}
}
return
result
;
}
public
static
List
<
string
>
DecodeBarCodes
(
Bitmap
bmp
)
{
if
(
rs
==
null
)
List
<
string
>
result
=
new
List
<
string
>();
BarcodeReader
br
=
new
BarcodeReader
();
DecodingOptions
decodeOption
=
new
DecodingOptions
();
decodeOption
.
PossibleFormats
=
new
List
<
BarcodeFormat
>()
{
BarcodeFormat
.
CODE_39
,
BarcodeFormat
.
CODE_128
};
br
.
Options
=
decodeOption
;
Result
res
=
br
.
Decode
(
bmp
);
if
(
res
!=
null
)
{
text
=
""
;
result
.
Add
(
res
.
ToString
())
;
}
else
return
result
;
}
public
static
List
<
string
>
DecodeDMCodes
(
Bitmap
bmp
)
{
ZXing
.
Datamatrix
.
DataMatrixReader
qc
=
new
ZXing
.
Datamatrix
.
DataMatrixReader
();
List
<
string
>
result
=
new
List
<
string
>();
LuminanceSource
source
=
new
BitmapLuminanceSource
(
bmp
);
BinaryBitmap
binarybitmap
=
new
BinaryBitmap
(
new
HybridBinarizer
(
source
));
IDictionary
<
DecodeHintType
,
object
>
hints
=
new
Dictionary
<
DecodeHintType
,
object
>();
hints
.
Add
(
DecodeHintType
.
CHARACTER_SET
,
"UTF-8"
);
hints
.
Add
(
DecodeHintType
.
TRY_HARDER
,
"3"
);
Result
res
=
qc
.
decode
(
binarybitmap
,
hints
);
if
(
res
!=
null
)
{
text
=
rs
.
ToString
();
if
(!
IsGBCode
(
text
))
result
.
Add
(
res
.
ToString
());
}
return
result
;
}
public
static
List
<
string
>
DecodeQRCodes
(
Bitmap
bmp
)
{
QRCodeMultiReader
qc
=
new
QRCodeMultiReader
();
List
<
string
>
result
=
new
List
<
string
>();
LuminanceSource
source
=
new
BitmapLuminanceSource
(
bmp
);
BinaryBitmap
binarybitmap
=
new
BinaryBitmap
(
new
HybridBinarizer
(
source
));
IDictionary
<
DecodeHintType
,
object
>
hints
=
new
Dictionary
<
DecodeHintType
,
object
>();
hints
.
Add
(
DecodeHintType
.
CHARACTER_SET
,
"GB2312"
);
hints
.
Add
(
DecodeHintType
.
TRY_HARDER
,
"3"
);
Result
[]
r
=
qc
.
decodeMultiple
(
binarybitmap
,
hints
);
if
(
r
!=
null
)
{
foreach
(
Result
res
in
r
)
{
text
=
ConvertISO88591ToEncoding
(
text
,
Encoding
.
Default
);
if
(
res
!=
null
)
{
string
text
=
res
.
ToString
();
//if (!IsGBCode(text))
//{
// string chStr = "生产日期(或厂家批次):";
// int index = text.IndexOf(chStr);
// if (index > 0)
// {
// string sub1 = text.Substring(0, index);
// int sub3startIndex =index+ chStr.Length;
// string sub3 = text.Substring(sub3startIndex,text.Length- sub3startIndex);
// string sub1r = ConvertISO88591ToEncoding(sub1, Encoding.Default);
// string sub3r = ConvertISO88591ToEncoding(sub3, Encoding.Default);
// text = sub1r + chStr + sub3r;
// }
// else
// {
// text = ConvertISO88591ToEncoding(text, Encoding.Default);
// }
//}
result
.
Add
(
text
);
}
}
}
return
tex
t
;
return
resul
t
;
}
//public static string DecodeQRCode(Bitmap bmp)
//{
// string text = "";
// DecodingOptions option = new DecodingOptions();
// //option.PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.QR_CODE, BarcodeFormat.All_1D };
// option.PossibleFormats = new List<BarcodeFormat>() { BarcodeFormat.QR_CODE };
// BarcodeReader br = new BarcodeReader();
// br.Options = option;
// Result rs = br.Decode(bmp);
// if (rs == null)
// {
// text = "";
// }
// else
// {
// text = rs.ToString();
// if (!IsGBCode(text))
// {
// text = ConvertISO88591ToEncoding(text, Encoding.Default);
// }
// }
// return text;
//}
//转换
private
static
string
ConvertISO88591ToEncoding
(
string
srcString
,
Encoding
dstEncode
)
{
...
...
CodeLibraryProject/CodeTest/CodeCreater.cs
查看文件 @
9b0cfda
...
...
@@ -26,7 +26,8 @@ namespace CodeTest
for
(
int
i
=
100000
;
i
<=
100000
+
count
;
i
++)
{
string
name
=
"pn;A"
+
i
.
ToString
().
PadLeft
(
6
,
'0'
)
+
";1000"
;
Bitmap
map
=
ZXingCode
(
name
,
200
,
BarcodeFormat
.
QR_CODE
);
Bitmap
map
=
ZXingCode
(
name
,
400
,
BarcodeFormat
.
CODE_128
);
// Bitmap map = DataMatrix(name, 200);
if
(
map
!=
null
)
{
map
.
Save
(
targetFilePath
+
name
+
".bmp"
);
...
...
@@ -49,6 +50,10 @@ namespace CodeTest
//设置二维码的宽度和高度
options
.
Width
=
codeSizeInPixels
;
options
.
Height
=
codeSizeInPixels
;
if
(
type
.
Equals
(
BarcodeFormat
.
CODE_128
))
{
options
.
Height
=
100
;
}
//设置二维码的边距,单位不是固定像素
options
.
Margin
=
1
;
writer
.
Options
=
options
;
...
...
@@ -94,7 +99,7 @@ namespace CodeTest
br
.
Options
=
option
;
Result
rs
=
br
.
Decode
(
bmp
);
if
(
rs
==
null
)
{
text
=
""
;
...
...
@@ -141,27 +146,24 @@ namespace CodeTest
dstEncode
.
GetChars
(
dstBytes
,
0
,
dstBytes
.
Length
,
dstChars
,
0
);
//利用char数组存储字符
sResult
=
new
string
(
dstChars
);
return
sResult
;
}
}
//}
///// <summary>
///// DataMatrix矩阵二维码
///// </summary>
///// <param name="text"></param>
///// <param name="size"></param>
///// <returns></returns>
//public static Bitmap DataMatrix(string text, int size)
//{
// if (size < 10) size = 10;
// DataMatrix.net.DmtxImageEncoderOptions opt = new DataMatrix.net.DmtxImageEncoderOptions();
// opt.ModuleSize = size;
// opt.MarginSize = 5;
// DataMatrix.net.DmtxImageEncoder encoder = new DataMatrix.net.DmtxImageEncoder();
// Bitmap bm = encoder.EncodeImage(text, opt);
// return bm;
//}
/// <summary>
/// DataMatrix矩阵二维码
/// </summary>
/// <param name="text"></param>
/// <param name="size"></param>
/// <returns></returns>
public
static
Bitmap
DataMatrix
(
string
text
,
int
size
)
{
if
(
size
<
10
)
size
=
10
;
DataMatrix
.
net
.
DmtxImageEncoderOptions
opt
=
new
DataMatrix
.
net
.
DmtxImageEncoderOptions
();
opt
.
ModuleSize
=
size
;
opt
.
MarginSize
=
5
;
DataMatrix
.
net
.
DmtxImageEncoder
encoder
=
new
DataMatrix
.
net
.
DmtxImageEncoder
();
Bitmap
bm
=
encoder
.
EncodeImage
(
text
,
opt
);
return
bm
;
}
}
}
CodeLibraryProject/CodeTest/Program.cs
查看文件 @
9b0cfda
...
...
@@ -18,13 +18,16 @@ namespace CodeTest
[
STAThread
]
static
void
Main
()
{
// CodeCreater.CreateCode(10);
// CodeCreater.CreateCode(10);
// return;
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
HDCodeLearnHelper
.
LoadConfig
(
ConfigAppSettings
.
GetValue
(
Setting_Init
.
CameraName
),
ConfigAppSettings
.
GetValue
(
Setting_Init
.
CodeType
));
Application
.
Run
(
new
FrmCodeDecode
());
//Application.Run(new FrmTest());
//Application.Run(new FrmTest());
//string filename = @"C:/Users/WORK/Desktop/西安二维码/IMG_20190730_165612.jpg";
//Bitmap img = (Bitmap)Image.FromFile(filename).Clone();
//string text= CodeCreater.DecodeQRCode(img);
...
...
CodeLibraryProject/dll/CodeLibrary.dll
查看文件 @
9b0cfda
此文件类型无法预览
CodeLibraryProject/编译好的DLL/CodeLibrary.dll
查看文件 @
9b0cfda
此文件类型无法预览
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论