Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
GeneralClassLibrary
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 941dda78
由
几米阳光
编写于
2019-02-25 16:16:33 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
国际化日志增加开关
1 个父辈
f2f4dc53
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
37 行增加
和
25 行删除
CodeLibraryProject/CodeLibrary/CodeResourceControl.cs
CodeLibraryProject/CodeLibrary/HDCodeHelper.cs
CodeLibraryProject/CodeLibrary/CodeResourceControl.cs
查看文件 @
941dda7
...
@@ -14,7 +14,7 @@ namespace CodeLibrary
...
@@ -14,7 +14,7 @@ namespace CodeLibrary
//public delegate string GetStringDelegate(string id, string defaultStr, params object[] param);
//public delegate string GetStringDelegate(string id, string defaultStr, params object[] param);
//public static event GetStringDelegate GetStringEvent;
//public static event GetStringDelegate GetStringEvent;
public
static
bool
OpenResourceLog
=
false
;
public
static
string
China
=
"zh-CN"
;
public
static
string
China
=
"zh-CN"
;
public
static
string
English
=
"en-US"
;
public
static
string
English
=
"en-US"
;
private
static
Dictionary
<
string
,
string
>
chineseMap
=
new
Dictionary
<
string
,
string
>();
private
static
Dictionary
<
string
,
string
>
chineseMap
=
new
Dictionary
<
string
,
string
>();
...
@@ -95,9 +95,10 @@ namespace CodeLibrary
...
@@ -95,9 +95,10 @@ namespace CodeLibrary
private
static
void
NoIdLog
(
string
id
,
string
defaultStr
)
private
static
void
NoIdLog
(
string
id
,
string
defaultStr
)
{
{
if
(
OpenResourceLog
)
{
HDLogUtil
.
info
(
"No id:["
+
id
+
"], please add,use default string :"
+
defaultStr
);
HDLogUtil
.
info
(
"No id:["
+
id
+
"], please add,use default string :"
+
defaultStr
);
}
}
}
static
CodeResourceControl
()
static
CodeResourceControl
()
{
{
...
...
CodeLibraryProject/CodeLibrary/HDCodeHelper.cs
查看文件 @
941dda7
...
@@ -21,26 +21,26 @@ namespace CodeLibrary
...
@@ -21,26 +21,26 @@ namespace CodeLibrary
/// </summary>
/// </summary>
public
static
HWindow
HalconWindow
=
null
;
public
static
HWindow
HalconWindow
=
null
;
///
//
<summary>
/// <summary>
///
//
根据图片路径解析二维码
/// 根据图片路径解析二维码
///
//
</summary>
/// </summary>
///
//
<param name="filePath">图片路径</param>
/// <param name="filePath">图片路径</param>
///
//
<param name="codeCount">二维码数量</param>
/// <param name="codeCount">二维码数量</param>
///
//
<param name="codeParamPath">二维码参数路径,""表示不使用参数</param>
/// <param name="codeParamPath">二维码参数路径,""表示不使用参数</param>
///
//
<param name="paramType">二维码类型,不传类型默认Data Matrix ECC 200</param>
/// <param name="paramType">二维码类型,不传类型默认Data Matrix ECC 200</param>
///
//
<returns>解析到的二维码</returns>
/// <returns>解析到的二维码</returns>
//public static List<string
> DecodeCode(string filePath, int codeCount, string codeParamPath, params string[] paramType)
public
static
List
<
CodeInfo
>
DecodeCode
(
string
filePath
,
int
codeCount
,
string
codeParamPath
,
params
string
[]
paramType
)
//
{
{
//
HObject ho_Image;
HObject
ho_Image
;
//
HOperatorSet.GenEmptyObj(out ho_Image);
HOperatorSet
.
GenEmptyObj
(
out
ho_Image
);
//
ho_Image.Dispose();
ho_Image
.
Dispose
();
//
HOperatorSet.ReadImage(out ho_Image, filePath);
HOperatorSet
.
ReadImage
(
out
ho_Image
,
filePath
);
//
if (HalconWindow != null)
if
(
HalconWindow
!=
null
)
//
{
{
//
HOperatorSet.DispObj(ho_Image, HalconWindow);
HOperatorSet
.
DispObj
(
ho_Image
,
HalconWindow
);
//
}
}
// return DecodeCode(ho_Image, codeCount,
codeParamPath, paramType);
return
DecodeCode
(
ho_Image
,
codeCount
,
codeParamPath
,
paramType
);
//
}
}
/// <summary>
/// <summary>
/// 根据图片解析二维码
/// 根据图片解析二维码
/// </summary>
/// </summary>
...
@@ -118,9 +118,10 @@ namespace CodeLibrary
...
@@ -118,9 +118,10 @@ namespace CodeLibrary
ShowImage
(
HalconWindow
,
ho_Image
,
ho_SymbolXLDs
);
ShowImage
(
HalconWindow
,
ho_Image
,
ho_SymbolXLDs
);
}
}
HOperatorSet
.
ClearDataCode2dModel
(
hv_DataCodeHandle
);
HOperatorSet
.
ClearDataCode2dModel
(
hv_DataCodeHandle
);
string
[]
resultList
=
hv_DecodedDataStrings
.
SArr
;
if
(
resultList
.
Length
>
0
)
if
(
hv_DecodedDataStrings
.
Length
>
0
)
{
{
string
[]
resultList
=
hv_DecodedDataStrings
.
SArr
;
for
(
int
i
=
0
;
i
<
hv_DecodedDataStrings
.
SArr
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
hv_DecodedDataStrings
.
SArr
.
Length
;
i
++)
{
{
try
try
...
@@ -144,6 +145,7 @@ namespace CodeLibrary
...
@@ -144,6 +145,7 @@ namespace CodeLibrary
HDLogUtil
.
error
(
"DecodeCode出错:"
+
ex
.
ToString
());
HDLogUtil
.
error
(
"DecodeCode出错:"
+
ex
.
ToString
());
return
codeList
;
return
codeList
;
}
}
}
}
internal
static
void
ShowImage
(
HWindow
window
,
HObject
ho_Image
,
HObject
ho_SymbolXLDs
)
internal
static
void
ShowImage
(
HWindow
window
,
HObject
ho_Image
,
HObject
ho_SymbolXLDs
)
{
{
...
@@ -221,6 +223,14 @@ namespace CodeLibrary
...
@@ -221,6 +223,14 @@ namespace CodeLibrary
string
filePath
=
appPath
+
codeType
+
".dcm"
;
string
filePath
=
appPath
+
codeType
+
".dcm"
;
return
filePath
;
return
filePath
;
}
}
public
static
List
<
CodeInfo
>
DecodeBarCode
(
string
filePath
)
{
HObject
ho_Image
;
HOperatorSet
.
GenEmptyObj
(
out
ho_Image
);
ho_Image
.
Dispose
();
HOperatorSet
.
ReadImage
(
out
ho_Image
,
filePath
);
return
DecodeBarCode
(
ho_Image
);
}
public
static
List
<
CodeInfo
>
DecodeBarCode
(
Bitmap
bitmap
)
public
static
List
<
CodeInfo
>
DecodeBarCode
(
Bitmap
bitmap
)
{
{
HObject
ho_image
=
Bitmap2HObjectBpp24
(
bitmap
);
HObject
ho_image
=
Bitmap2HObjectBpp24
(
bitmap
);
...
@@ -285,6 +295,7 @@ namespace CodeLibrary
...
@@ -285,6 +295,7 @@ namespace CodeLibrary
}
}
}
}
HOperatorSet
.
ClearBarCodeModel
(
hv_BarCodeHandle
);
HOperatorSet
.
ClearBarCodeModel
(
hv_BarCodeHandle
);
return
codeList
;
return
codeList
;
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论