Exemplo n.º 1
0
void SetFunctionModule(void)
{
	int i, j;

	// Position detection pattern
	SetFinderPattern(0, 0);
	SetFinderPattern(m_nSymbleSize - 7, 0);
	SetFinderPattern(0, m_nSymbleSize - 7);

	// Separator pattern position detection
	for (i = 0; i < 8; i++) {
		m_byModuleData[i][7] = m_byModuleData[7][i] = '\x20';
		m_byModuleData[m_nSymbleSize - 8][i] = m_byModuleData[m_nSymbleSize - 8 + i][7] = '\x20';
		m_byModuleData[i][m_nSymbleSize - 8] = m_byModuleData[7][m_nSymbleSize - 8 + i] = '\x20';
	}

	// Registration as part of a functional module position description format information
	for (i = 0; i < 9; i++) {
		m_byModuleData[i][8] = m_byModuleData[8][i] = '\x20';
	}

	for (i = 0; i < 8; i++) {
		m_byModuleData[m_nSymbleSize - 8 + i][8] = m_byModuleData[8][m_nSymbleSize - 8 + i] = '\x20';
	}

	// Version information pattern
	SetVersionPattern();

	// Pattern alignment
	for (i = 0; i < QR_VersonInfo[m_nVersion].ncAlignPoint; i++) {
		SetAlignmentPattern(QR_VersonInfo[m_nVersion].nAlignPoint[i], 6);
		SetAlignmentPattern(6, QR_VersonInfo[m_nVersion].nAlignPoint[i]);

		for (j = 0; j < QR_VersonInfo[m_nVersion].ncAlignPoint; j++) {
			SetAlignmentPattern(QR_VersonInfo[m_nVersion].nAlignPoint[i], QR_VersonInfo[m_nVersion].nAlignPoint[j]);
		}
	}

	// Timing pattern
	for (i = 8; i <= m_nSymbleSize - 9; i++) {
		m_byModuleData[i][6] = (i % 2) == 0 ? '\x30' : '\x20';
		m_byModuleData[6][i] = (i % 2) == 0 ? '\x30' : '\x20';
	}
}
Exemplo n.º 2
0
void SetFunctionModule(void)
{
	int i, j;

	SetFinderPattern(0, 0);
	SetFinderPattern(m_nSymbleSize - 7, 0);
	SetFinderPattern(0, m_nSymbleSize - 7);

	for (i = 0; i < 8; ++i)
	{
		m_byModuleData[i][7] = m_byModuleData[7][i] = '\x20';
		m_byModuleData[m_nSymbleSize - 8][i] = m_byModuleData[m_nSymbleSize - 8 + i][7] = '\x20';
		m_byModuleData[i][m_nSymbleSize - 8] = m_byModuleData[7][m_nSymbleSize - 8 + i] = '\x20';
	}

	for (i = 0; i < 9; ++i)
	{
		m_byModuleData[i][8] = m_byModuleData[8][i] = '\x20';
	}

	for (i = 0; i < 8; ++i)
	{
		m_byModuleData[m_nSymbleSize - 8 + i][8] = m_byModuleData[8][m_nSymbleSize - 8 + i] = '\x20';
	}

	SetVersionPattern();

	for (i = 0; i < QR_VersonInfo[m_nVersion].ncAlignPoint; ++i)
	{
		SetAlignmentPattern(QR_VersonInfo[m_nVersion].nAlignPoint[i], 6);
		SetAlignmentPattern(6, QR_VersonInfo[m_nVersion].nAlignPoint[i]);

		for (j = 0; j < QR_VersonInfo[m_nVersion].ncAlignPoint; ++j)
		{
			SetAlignmentPattern(QR_VersonInfo[m_nVersion].nAlignPoint[i], QR_VersonInfo[m_nVersion].nAlignPoint[j]);
		}
	}

	for (i = 8; i <= m_nSymbleSize - 9; ++i)
	{
		m_byModuleData[i][6] = (i % 2) == 0 ? '\x30' : '\x20';
		m_byModuleData[6][i] = (i % 2) == 0 ? '\x30' : '\x20';
	}
}
Exemplo n.º 3
0
bool ContentDecoder::DecodeData(int nCodeSize,int nVersion,unsigned char CodeData[MAX_MODULESIZE][MAX_MODULESIZE])
{
	int i,j;

	m_nCodeSize=nCodeSize;
	m_nVersion=nVersion;
	for(i=0;i<nCodeSize;i++)
		for(j=0;j<nCodeSize;j++)
			m_CodeData[i][j]=CodeData[i][j];

	//获取版本信息(7~40有版本信息)
	//if(m_nVersion>=7)
	//{
	//	m_nVersion=GetVersionInfo();
	//}

	//获取格式信息
	int nFormatData=GetFormatInfo();

	m_nLevel=((nFormatData & 0x18) >> 3);//纠错级别,前两位
	switch(m_nLevel)
	{
	case 1: m_nLevel=QR_LEVEL_L;break;
	case 0: m_nLevel=QR_LEVEL_M;break;
	case 3: m_nLevel=QR_LEVEL_Q;break;
	case 2: m_nLevel=QR_LEVEL_H;break;
	}
	m_nMaskingNo=(nFormatData & 0x07);//掩膜图形参考,后三位

	//去除掩膜图形
	for(i=0;i<m_nCodeSize;++i)
	{
		for(j=0;j<m_nCodeSize;++j)
		{
			bool bMask;
			switch (m_nMaskingNo)
			{
			case 0:
				bMask=((i+j)%2==0);break;
			case 1:
				bMask=(i%2==0);break;
			case 2:
				bMask=(j%3==0);break;
			case 3:
				bMask=((i+j) % 3 == 0);break;
			case 4:
				bMask=(((i/2)+(j/3))%2==0);break;
			case 5:
				bMask=(((i*j)%2)+((i*j)%3)==0);break;
			case 6:
				bMask=((((i*j)%2)+((i* j)%3))%2==0);break;
			default: // case 7:
				bMask=((((i*j)%3)+((i+j)%2))%2==0);break;
			}
			m_CodeData[j][i] = (unsigned char)(m_CodeData[j][i] ^ bMask);
		}
	}

	//标记非数据位置
	SetFinderPattern();
	if(m_nVersion>1)
		SetAlignmentPattern();
	SetFormatPattern();
	SetVersionPattern();

	//读取数据位置,得到数据位流
	GetCodeWord();

	//纠错
	CorrectDataBlocks();

	//解析数据码字,得到字符串
	ParseDataCodeWord();

	return true;
}