ZBar源码分析:zbar_symbol(2)
作者:互联网
2021SC@SDUSC
zbar.h中定义解码符号类型zbar_symbol_type_e,对不同条形码类型进行定义:
typedef enum zbar_symbol_type_e {
ZBAR_NONE = 0,
ZBAR_PARTIAL = 1,
ZBAR_EAN2 = 2,
ZBAR_EAN5 = 5,
ZBAR_EAN8 = 8,
ZBAR_UPCE = 9,
ZBAR_ISBN10 = 10,
ZBAR_UPCA = 12,
ZBAR_EAN13 = 13,
ZBAR_ISBN13 = 14,
ZBAR_COMPOSITE = 15,
ZBAR_I25 = 25,
ZBAR_DATABAR = 34,
ZBAR_DATABAR_EXP = 35,
ZBAR_CODABAR = 38,
ZBAR_CODE39 = 39,
ZBAR_PDF417 = 57,
ZBAR_QRCODE = 64,
ZBAR_CODE93 = 93,
ZBAR_CODE128 = 128,
ZBAR_SYMBOL = 0x00ff,
ZBAR_ADDON2 = 0x0200,
ZBAR_ADDON5 = 0x0500,
ZBAR_ADDON = 0x0700,
} zbar_symbol_type_t;
symbol.c中实现了zbar_get_symbol_name函数检索符号编码的字符串名称。返回指定符号类型的静态字符串名称,如果编码无法识别,则为“UNKNOWN”:
const char *zbar_get_symbol_name (zbar_symbol_type_t sym)
{
switch(sym & ZBAR_SYMBOL) {
case ZBAR_EAN2: return("EAN-2");
case ZBAR_EAN5: return("EAN-5");
case ZBAR_EAN8: return("EAN-8");
case ZBAR_UPCE: return("UPC-E");
case ZBAR_ISBN10: return("ISBN-10");
case ZBAR_UPCA: return("UPC-A");
case ZBAR_EAN13: return("EAN-13");
case ZBAR_ISBN13: return("ISBN-13");
case ZBAR_COMPOSITE: return("COMPOSITE");
case ZBAR_I25: return("I2/5");
case ZBAR_DATABAR: return("DataBar");
case ZBAR_DATABAR_EXP: return("DataBar-Exp");
case ZBAR_CODABAR: return("Codabar");
case ZBAR_CODE39: return("CODE-39");
case ZBAR_CODE93: return("CODE-93");
case ZBAR_CODE128: return("CODE-128");
case ZBAR_PDF417: return("PDF417");
case ZBAR_QRCODE: return("QR-Code");
default: return("UNKNOWN");
}
}
symbol.c中实现了zbar_get_config_name函数检索配置设置的字符串名称。返回配置的静态字符串名称,如果值不是已知配置,则返回空字符串。
const char *zbar_get_config_name (zbar_config_t cfg)
{
switch(cfg) {
case ZBAR_CFG_ENABLE: return("ENABLE");
case ZBAR_CFG_ADD_CHECK: return("ADD_CHECK");
case ZBAR_CFG_EMIT_CHECK: return("EMIT_CHECK");
case ZBAR_CFG_ASCII: return("ASCII");
case ZBAR_CFG_MIN_LEN: return("MIN_LEN");
case ZBAR_CFG_MAX_LEN: return("MAX_LEN");
case ZBAR_CFG_UNCERTAINTY: return("UNCERTAINTY");
case ZBAR_CFG_POSITION: return("POSITION");
case ZBAR_CFG_X_DENSITY: return("X_DENSITY");
case ZBAR_CFG_Y_DENSITY: return("Y_DENSITY");
default: return("");
}
}
zbar_get_modifier_name函数检索修饰符的字符串名称。返回修饰符的静态字符串名称,如果值不是已知标志,则为空字符串。
const char *zbar_get_modifier_name (zbar_modifier_t mod)
{
switch(mod) {
case ZBAR_MOD_GS1: return("GS1");
case ZBAR_MOD_AIM: return("AIM");
default: return("");
}
}
zbar_get_orientation_name函数检索定向的字符串名称。返回指定方向的静态字符串名称,如果无法识别方向,则为“UNKNOWN”:
const char *zbar_get_orientation_name (zbar_orientation_t orient)
{
switch(orient) {
case ZBAR_ORIENT_UP: return("UP");
case ZBAR_ORIENT_RIGHT: return("RIGHT");
case ZBAR_ORIENT_DOWN: return("DOWN");
case ZBAR_ORIENT_LEFT: return("LEFT");
default: return("UNKNOWN");
}
}
标签:case,zbar,return,CFG,symbol,源码,ZBAR,ZBar 来源: https://blog.csdn.net/weixin_46032754/article/details/121736873