QRCode二维条码开发(计算格式信息)_2011.05.25
2011-05-25 17:09
162 查看
//函数功能:根据不同的纠错等级,计算15位的格式信息:BCH(15,5)
//参数说明:
//chErrLevel -- 纠错等级
//返回值:strFormatInformation -- 数据码字
CString CQRCodeDlg::CalculateFormatInformation(CString chErrLevel)
{
/*掩膜图形暂选101,因为一个图形一次只能选择一种掩膜方式*/
CString strFormatInformation;/*15位的格式信息串*/
CString strGeneratorInfo = "000010100110111";/*生成多项式信息串*/
CString strDataInfo;/*15位数据信息*/
char* cErrLevel;/*纠错等级*/
char buffer[15];
int nFlag1 = 16;/*非0位置标记,随便赋一个值*/
int nFlag2 = 16;/*非0位置标记,随便赋一个值*/
int nGeneratorInfo = 0;
int nDataInfo = 0;
cErrLevel = (LPSTR)(LPCSTR)chErrLevel;/*cstring类型数据转换为char型数据*/
switch(*cErrLevel)
{
case 'L':
strDataInfo = "011010000000000";/*数据信息位赋值,占据前5位*/
break;
case 'M':
strDataInfo = "001010000000000";
break;
case 'Q':
strDataInfo = "111010000000000";
break;
case 'H':
strDataInfo = "101010000000000";
break;
}
for(int i=0;i<15;i++)
{
if (strGeneratorInfo[i] == '1' && nFlag1 == 16)
nFlag1 = i;/*除数,根据差值进行移位*/
if (strDataInfo[i] == '1' && nFlag2 == 16)
nFlag2 = i;/*被除数*/
}
/*nFlag1>nFlag2,则需进行移位,然后进行位运算操作,同者为0,不同为1*/
nDataInfo = strtol(strDataInfo,NULL,2);
nGeneratorInfo = strtol(strGeneratorInfo,NULL,2)<<(nFlag1 - nFlag2);/*通过移位做除法*/
_itoa(nDataInfo^nGeneratorInfo,buffer,2);
strFormatInformation.Format("%015s",buffer);
strFormatInformation = strDataInfo.Left(5) + strFormatInformation.Right(10);
_itoa(strtol(strFormatInformation,NULL,2)^strtol("101010000010010",NULL,2),buffer,2);
strFormatInformation.Format("%015s",buffer);
return strFormatInformation;
}
//参数说明:
//chErrLevel -- 纠错等级
//返回值:strFormatInformation -- 数据码字
CString CQRCodeDlg::CalculateFormatInformation(CString chErrLevel)
{
/*掩膜图形暂选101,因为一个图形一次只能选择一种掩膜方式*/
CString strFormatInformation;/*15位的格式信息串*/
CString strGeneratorInfo = "000010100110111";/*生成多项式信息串*/
CString strDataInfo;/*15位数据信息*/
char* cErrLevel;/*纠错等级*/
char buffer[15];
int nFlag1 = 16;/*非0位置标记,随便赋一个值*/
int nFlag2 = 16;/*非0位置标记,随便赋一个值*/
int nGeneratorInfo = 0;
int nDataInfo = 0;
cErrLevel = (LPSTR)(LPCSTR)chErrLevel;/*cstring类型数据转换为char型数据*/
switch(*cErrLevel)
{
case 'L':
strDataInfo = "011010000000000";/*数据信息位赋值,占据前5位*/
break;
case 'M':
strDataInfo = "001010000000000";
break;
case 'Q':
strDataInfo = "111010000000000";
break;
case 'H':
strDataInfo = "101010000000000";
break;
}
for(int i=0;i<15;i++)
{
if (strGeneratorInfo[i] == '1' && nFlag1 == 16)
nFlag1 = i;/*除数,根据差值进行移位*/
if (strDataInfo[i] == '1' && nFlag2 == 16)
nFlag2 = i;/*被除数*/
}
/*nFlag1>nFlag2,则需进行移位,然后进行位运算操作,同者为0,不同为1*/
nDataInfo = strtol(strDataInfo,NULL,2);
nGeneratorInfo = strtol(strGeneratorInfo,NULL,2)<<(nFlag1 - nFlag2);/*通过移位做除法*/
_itoa(nDataInfo^nGeneratorInfo,buffer,2);
strFormatInformation.Format("%015s",buffer);
strFormatInformation = strDataInfo.Left(5) + strFormatInformation.Right(10);
_itoa(strtol(strFormatInformation,NULL,2)^strtol("101010000010010",NULL,2),buffer,2);
strFormatInformation.Format("%015s",buffer);
return strFormatInformation;
}
相关文章推荐
- QRCode二维条码开发(计算版本信息)_2011.06.01
- jplogic v1.0 开发案例--知识库管理(视频资料上传、格式转化、视频截图、视频预览、视频信息索引检索)
- QRCode二维条码开发(代码)_2011.05.24
- QRCode二维条码开发
- 为方便储户,某银行拟开发计算机储蓄系统。储户填写的存款单或取款单由业务员输入系统,如果是存款,系统记录存款人姓名、住址、存款类型、存款日期、利率等信息,并印出存款单给储户;如果是取款,系统计算利息并印出利息清单给储户。 写出问题定义并分析系统的可行性。
- Android手机开发:日期函数之判断某日期格式是否之前+计算某日期之前N天或之后N天的日期
- QRCode二维条码开发(代码)_2011.05.24
- 2.为方便储户,某银行拟开发计算机储蓄系统。储户填写的存款单或取款单由业务员输入系统,如果是存款,系统纪录存款人姓名、住址、存款类型、存款日期、利率等信息,并打印出存款单给储户;如果是取款,系统计算利息并打印利息清单给储户。
- QRCode二维条码开发_2011.05.23
- 【Android开发】JSON格式传送网络信息
- 2-2 为方便储户,某银行拟开发计算机储蓄系统。储户填写的存款单或取款单由业务员键入系统,如果是存款,系统记录存款人姓名、住址、存款类型、存款日期、利率等信息,并印出存款单给储户;如果是取款,系统计算利息并印出利息清单给储户。请写出问题定义并分析此系统的可行性。
- 有五个学生,每个学生有3门课的成绩, 从键盘输入以上数据(包括姓名,三门课成绩), 输入的格式:如:zhagnsan,30,40,60计算出总成绩, 并把学生的信息和计算出的总分数高低顺序存放在磁盘文
- Andorid开发之银联ISO8583报文格式、组包和解包过程、TPDU、位图计算过程
- 2.为方便储户,某银行拟开发计算机储蓄系统。储户填写的存款单或取款单由业务员键入系统,如果是存款,系统记录存款人姓名、住址、存款类型、存款日期、利率等信息,并印出存款单给储户;如果是取款,系统计算利息并印出利息清单给储户。 请写出问题定义并分析此系统的可行性。
- NDK开发中JNI打印log信息
- python脚本:根据视差图制作npy格式的深度信息文件
- Wav数据格式的44个字节头部信息汇总
- android开发:日期格式大全以及把毫秒转换成日期格式
- 在多模块开发的时候,利用项目继承可以将结构信息、部署信息,将共同的依赖放在一个父类中。
- 音视频开发技术之排查故障信息