/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define UPCA_C
/******************************************************************************
* *
* C O M P I L E R D E F I N E D I N C L U D E F I L E S *
* *
******************************************************************************/
#include <string.h>
#include <ctype.h>
/******************************************************************************
* *
* U S E R D E F I N E D I N C L U D E F I L E S *
* *
******************************************************************************/
#include "Common.h"
#include "XGraphic.h"
#include "Barcode.h"
/******************************************************************************
* *
* L O C A L D E F I N E S *
* *
******************************************************************************/
#if defined(TSPL_VER_1)
#define QUIET_MU 16
#else
#define QUIET_MU 0
#endif
#define GuardMu 5
#define AddMu 10
#define TOTAL_CHAR 18 // (11 + 1 + 5 + 1)
#define UPCA_STR_LEN 11
/******************************************************************************
* *
* L O C A L T Y P E D E F S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* L O C A L F U N C T I O N P R O T O T Y P E S *
* *
******************************************************************************/
/* None */
/******************************************************************************
* *
* L O C A L I N I T I A L I Z E D D A T A D E F I N I T I O N S *
* *
******************************************************************************/
CONST STATIC BYTE Chara[3][10][5] =
{
3,2,1,1,1, // A
2,2,2,1,1,
2,1,2,2,2,
1,4,1,1,1,
1,1,3,2,2,
1,2,3,1,1,
1,1,1,4,4,
1,3,1,2,2,
1,2,1,3,3,
3,1,1,2,2,
0,3,2,1,1, // C
0,2,2,2,1,
0,2,1,2,2,
0,1,4,1,1,
0,1,1,3,2,
0,1,2,3,1,
0,1,1,1,4,
0,1,3,1,2,
0,1,2,1,3,
0,3,1,1,2,
1,1,2,3,3, // B
1,2,2,2,2,
2,2,1,2,2,
1,1,4,1,1,
2,3,1,1,1,
1,3,2,1,1,
4,1,1,1,1,
2,1,3,1,1,
3,1,2,1,1,
2,1,1,3,3
};
CONST STATIC BYTE Add2[4][2] =
{
0,0,
0,2,
2,0,
2,2
};
CONST STATIC BYTE Add5[10][5] =
{
2,2,0,0,0,
2,0,2,0,0,
2,0,0,2,0,
2,0,0,0,2,
0,2,2,0,0,
0,0,2,2,0,
0,0,0,2,2,
0,2,0,2,0,
0,2,0,0,2,
0,0,2,0,2
};
CONST STATIC BYTE Weight2Sub[] = {0, 2, 4, 6, 8, 9, 1, 3, 5, 7};
CONST STATIC BYTE Weight3[] = {0, 3, 6, 9, 2, 5, 8, 1, 4, 7};
CONST STATIC BYTE Weight5Add[] = {0, 5, 1, 6, 2, 7, 3, 8, 4, 9};
CONST STATIC BYTE Weight5Sub[] = {0, 5, 9, 4, 8, 3, 7, 2, 6, 1};
CONST STATIC BYTE FindWeight5Sub[] = {0, 9, 7, 5, 3, 1, 8, 6, 4, 2};
/******************************************************************************
* *
* L O C A L U N I T I A L I Z E D D A T A D E F I N I T I O N S *
* *
******************************************************************************/
/******************************************************************************
*
* Function:
*
*
* Description:
*
*
* Input:
* None
*
* Output:
* None.
*
******************************************************************************/
STATIC VOID RecognizeUpca(BYTE *Target, BYTE *Source, INT MexLen)
{
INT Length;
INT TOffset;
Length = strlen((CHAR *)Source);
TOffset = 0;
if ( Length < MexLen )
{
memset(Target, '0', MexLen - Length);
TOffset = MexLen - Length;
}
while ( TOffset < MexLen )
{
if ( isdigit( *Source ) )
*( Target + TOffset ) = *Source;
else
*( Target + TOffset ) = '0';
Source += 1;
TOffset += 1;
}
*( Target + TOffset ) = '\0';
}
INT Upca(_BarCodeAttr *psBarCodeAttr)
{
_BarAttr sBarAttr;
_TextAttr sTextAttr;
BYTE aValue[18], aHum[18], aString[6], *pValue, *pHum, *pText;
BYTE TargetStr[18];
INT i, j, k, iQuiet, iGuard, iAdd, iAddSpace;
INT iOdd, iEven, iSum, iCheck; // Used by check sum
INT Height;
sBarAttr.psImageBuffer = psBarCodeAttr->psImageBuffer;
sBarAttr.iType = DRAW_BAR;
if ( psBarCodeAttr->eLanguage == LANG_ZPL )
{
if ( psBarCodeAttr->iCheck == 2 )
RecognizeUpca(TargetStr, psBarCodeAttr->pExp, UPCA_STR_LEN + 2);
else if ( psBarCodeAttr->iCheck == 5 )
RecognizeUpca(TargetStr, psBarCodeAttr->pExp, UPCA_STR_LEN + 5);
else
RecognizeUpca(TargetStr, psBarCodeAttr->pExp, UPCA_STR_LEN );
pText = TargetStr;
}
else if ( psBarCodeAttr->eLanguage == LANG_DPL )
{
strcpy((CHAR *)TargetStr, (CHAR *)psBarCodeAttr->pExp);
pValue = (BYTE *)strchr((CHAR *)TargetStr, 'V');
pText = TargetStr;
// Five-Digit Price Field Calculation
if ((pValue - pText) == 5)
{
// Weighting Factor (5+) (2-) (5-) (5+) (2-)
iSum = Weight5Add[*(pValue + 1) - '0'];
iSum += Weight2Sub[*(pValue + 2) - '0'];
iSum += Weight5Sub[*(pValue + 3) - '0'];
iSum += Weight5Add[*(pValue + 4) - '0'];
iSum += Weight2Sub[*(pValue + 5) - '0'];
// Subtract the result from the nearest equal or higher multiple of 10
iCheck = 10 - iSum % 10;
// Take the result and search for the same number in the figure weighting factor (5-)
*pValue = FindWeight5Sub[iCheck] + '0';
}
// Four-Digit Price Field Calculation
else if ((pValue - pText) == 6)
{
// Weighting Factor (2-) (2-) (3) (5-)
iSum = Weight2Sub[*(pValue + 1) - '0'];
iSum += Weight2Sub[*(pValue + 2) - '0'];
iSum += Weight3 [*(pValue + 3) - '0'];
iSum += Weight5Sub[*(pValue + 4) - '0'];
// Multiply the result of step 3 by the factor 3
iCheck = Weight3[iSum % 10];
// The units digit of the result is the Price Verifier Digit.
*pValue = iCheck + '0';
}
}
else
pText = psBarCodeAttr->pExp;
sTextAttr.eLanguage = psBarCodeAttr->eLanguage;
sTextAttr.ePutWay = psBarCodeAttr->ePutWay;
#if defined(TSPL_VER_1)
if ( psBarCodeAttr->eLanguage == LANG_EPL )
iQuiet = (psBarCodeAttr->iNarrow << 3);
else
iQuiet = QUIET_MU;
#else
if ( psBarCodeAttr->eLanguage == LANG_EPL )
iQuiet = (psBarCodeAttr->iNarrow << 3);
else
iQuiet = QUIET_MU * psBarCodeAttr->iNarrow;
#endif
iGuard = GuardMu * psBarCodeAttr->iNarrow; // 5
iAdd = AddMu * psBarCodeAttr->iNarrow; // 5
iAddSpace = iAdd;
if (psBarCodeAttr->eLanguage == LANG_EPL && psBarCodeAttr->iHuman == 0)
iAdd = 0;
// Check digit character
iOdd = 0;
iEven = 0;
pValue = aValue;
pHum = aHum;
Height = psBarCodeAttr->iHeight;
#if defined(TSPL_VER_1)
if ( psBarCodeAttr->iHuman != 0 )
Height -= iGuard;
#endif
for ( i = 0 ; i < 11 ; i++ ) // The total character need 11 number
{
if ( *pText < '0' || *pText > '9' )
return FALSE;
*pHum = *pText;
*pValue = *pText - '0';
if ( i % 2 == 0 )
iOdd += *pValue;
else
iEven += *pValue;
pHum += 1;
pValue += 1;
pText += 1;
}
if (psBarCodeAttr->eLanguage == LANG_EPL)
{
if (psBarCodeAttr->iCheck == 2 && strlen((CHAR *)psBarCodeAttr->pExp) > UPCA_STR_LEN + 2)
pText += 1;
if (psBarCodeAttr->iCheck == 5 && strlen((CHAR *)psBarCodeAttr->pExp) > UPCA_STR_LEN + 5)
pText += 1;
}
// Check Sum
iSum = iOdd * 3 + iEven;
iCheck = 10 - iSum % 10;
if ( iCheck == 10 )
iCheck = 0;
*pValue = (BYTE)iCheck;
*pHum = (BYTE)iCheck + '0';
pHum += 1;
*pHum = 0;
// START character
switch ( psBarCodeAttr->iRotation )
{
case 0:
{
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.iHeight = Height;
else
sBarAttr.iHeight = Height + iGuard;
sBarAttr.sCoord.iX = psBarCodeAttr->sCoord.iX + iQuiet;
sBarAttr.sCoord.iY = psBarCodeAttr->sCoord.iY;
sBarAttr.iWidth = psBarCodeAttr->iNarrow; /* draw bar 101 */
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow;
// sBarAttr.iHeight = Height;
sTextAttr.sCoord.iX = psBarCodeAttr->sCoord.iX + iQuiet - 7 * psBarCodeAttr->iNarrow;
sTextAttr.sCoord.iY = psBarCodeAttr->sCoord.iY + Height;
break;
}
case 90:
{
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
{
sBarAttr.iWidth = Height;
sBarAttr.sCoord.iX = psBarCodeAttr->sCoord.iX - Height;
}
else
{
sBarAttr.iWidth = Height + iGuard;
sBarAttr.sCoord.iX = psBarCodeAttr->sCoord.iX - Height - iGuard;
}
sBarAttr.sCoord.iY = psBarCodeAttr->sCoord.iY + iQuiet;
sBarAttr.iHeight = psBarCodeAttr->iNarrow; /* draw bar 101 */
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow;
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.sCoord.iX -= iGuard;
// sBarAttr.sCoord.iX += iGuard;
// sBarAttr.iWidth = Height;
sTextAttr.sCoord.iX = psBarCodeAttr->sCoord.iX - Height;
sTextAttr.sCoord.iY = psBarCodeAttr->sCoord.iY + iQuiet - 7 * psBarCodeAttr->iNarrow;
break;
}
case 180:
{
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
{
sBarAttr.iHeight = Height;
sBarAttr.sCoord.iY = psBarCodeAttr->sCoord.iY - Height;
}
else
{
sBarAttr.iHeight = Height + iGuard;
sBarAttr.sCoord.iY = psBarCodeAttr->sCoord.iY - Height - iGuard;
}
sBarAttr.sCoord.iX = psBarCodeAttr->sCoord.iX - iQuiet;
sBarAttr.iWidth = psBarCodeAttr->iNarrow; /* draw bar 101 */
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.sCoord.iY -= iGuard;
// sBarAttr.sCoord.iY += iGuard;
// sBarAttr.iHeight = Height;
sTextAttr.sCoord.iX = psBarCodeAttr->sCoord.iX - iQuiet + 7 * psBarCodeAttr->iNarrow;
sTextAttr.sCoord.iY = psBarCodeAttr->sCoord.iY - Height;
break;
}
case 270:
{
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.iWidth = Height;
else
sBarAttr.iWidth = Height + iGuard;
sBarAttr.sCoord.iX = psBarCodeAttr->sCoord.iX;
sBarAttr.sCoord.iY = psBarCodeAttr->sCoord.iY - iQuiet;
sBarAttr.iHeight = psBarCodeAttr->iNarrow; /* draw bar 101 */
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
// sBarAttr.iWidth = Height;
sTextAttr.sCoord.iX = psBarCodeAttr->sCoord.iX + Height;
sTextAttr.sCoord.iY = psBarCodeAttr->sCoord.iY - iQuiet + 7 * psBarCodeAttr->iNarrow;
break;
}
}
pHum = aHum;
pValue = aValue;
/* human readable */
if ( psBarCodeAttr->iHuman != 0 )
{
sTextAttr.psImageBuffer = psBarCodeAttr->psImageBuffer;
sTextAttr.pFont = psBarCodeAttr->pFont;
sTextAttr.iDirection = psBarCodeAttr->iRotation;
sTextAttr.iRotation = psBarCodeAttr->iRotation;
sTextAttr.iDistance = 0;
sTextAttr.iHoriMulti = psBarCodeAttr->FontHoriMulti;
sTextAttr.iVertMulti = psBarCodeAttr->FontVertMulti;
*aString = *pHum++;
*(aString + 1) = 0;
sTextAttr.ExpLength = strlen((CHAR *)aString);
sTextAttr.pExp = aString;
OutText(&sTextAttr);
switch ( psBarCodeAttr->iRotation )
{
case 0:
sTextAttr.sCoord.iX += (2 * 7 + 3) * psBarCodeAttr->iNarrow;
break;
case 90:
sTextAttr.sCoord.iY += (2 * 7 + 3) * psBarCodeAttr->iNarrow;
break;
case 180:
sTextAttr.sCoord.iX -= (2 * 7 + 3) * psBarCodeAttr->iNarrow;
break;
case 270:
sTextAttr.sCoord.iY -= (2 * 7 + 3) * psBarCodeAttr->iNarrow;
break;
}
for ( i = 0 ; i < 5 ; i++ )
*(aString + i) = *pHum++;
*(aString + i) = 0;
sTextAttr.ExpLength = strlen((CHAR *)aString);
sTextAttr.pExp = aString;
OutText(&sTextAttr);
switch ( psBarCodeAttr->iRotation )
{
case 0:
sTextAttr.sCoord.iX += (5 * 7 + 4) * psBarCodeAttr->iNarrow;
break;
case 90:
sTextAttr.sCoord.iY += (5 * 7 + 4) * psBarCodeAttr->iNarrow;
break;
case 180:
sTextAttr.sCoord.iX -= (5 * 7 + 4) * psBarCodeAttr->iNarrow;
break;
case 270:
sTextAttr.sCoord.iY -= (5 * 7 + 4) * psBarCodeAttr->iNarrow;
break;
}
for ( i = 0 ; i < 5 ; i++ )
*(aString + i) = *pHum++;
*(aString + i) = 0;
sTextAttr.ExpLength = strlen((CHAR *)aString);
sTextAttr.pExp = aString;
OutText(&sTextAttr);
switch ( psBarCodeAttr->iRotation )
{
case 0:
sTextAttr.sCoord.iX += (6 * 7 + 4) * psBarCodeAttr->iNarrow;
break;
case 90:
sTextAttr.sCoord.iY += (6 * 7 + 4) * psBarCodeAttr->iNarrow;
break;
case 180:
sTextAttr.sCoord.iX -= (6 * 7 + 4) * psBarCodeAttr->iNarrow;
break;
case 270:
sTextAttr.sCoord.iY -= (6 * 7 + 4) * psBarCodeAttr->iNarrow;
break;
}
*aString = *pHum++;
*(aString + 1) = 0;
sTextAttr.ExpLength = strlen((CHAR *)aString);
sTextAttr.pExp = aString;
OutText(&sTextAttr);
}
for ( j = 0 ; j < 2 ; j++ )
{
switch ( psBarCodeAttr->iRotation )
{
case 0:
{
for ( k = 0 ; k < 6 ; k++ )
{
for ( i = 0 ; i < 4 ; i++ )
{
sBarAttr.sCoord.iX += Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
i += 1;
sBarAttr.iWidth = Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
}
if ( j == 0 && k == 0 )
{
sBarAttr.iHeight = Height;
}
else if ( j == 1 && k == 4 )
{
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.iHeight = Height;
else
sBarAttr.iHeight = Height + iGuard;
}
if ( j == 1 )
{
sBarAttr.sCoord.iX += Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
}
pValue += 1;
}
if ( j == 0 ) /* center character */
{
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.iHeight = Height;
else
sBarAttr.iHeight = Height + iGuard;
sBarAttr.iWidth = psBarCodeAttr->iNarrow; /* draw bar 01010 */
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
sBarAttr.iHeight = Height;
}
break;
}
case 90:
{
for ( k = 0 ; k < 6 ; k++ )
{
for ( i = 0 ; i < 4 ; i++ )
{
sBarAttr.sCoord.iY += Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
i += 1;
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && k == 0 && j == 0 && i < 2 && psBarCodeAttr->eLanguage != LANG_ZPL)
{
if ( i == 0 )
sBarAttr.sCoord.iX += (iGuard << 1);
else
sBarAttr.sCoord.iX += iGuard;
}
sBarAttr.iHeight = Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && k == 0 && j == 0 && i < 4 && psBarCodeAttr->eLanguage != LANG_ZPL)
{
if ( i != 1 )
sBarAttr.sCoord.iX -= iGuard;
}
}
if ( j == 0 && k == 0 )
{
sBarAttr.sCoord.iX += iGuard;
sBarAttr.iWidth = Height;
}
else if ( j == 1 && k == 4 )
{
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
{
sBarAttr.iWidth = Height;
}
else
{
sBarAttr.iWidth = Height + iGuard;
sBarAttr.sCoord.iX -= iGuard;
}
}
if ( j == 1)
{
sBarAttr.sCoord.iY += Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
}
pValue += 1;
}
if ( j == 0 ) /* center character */
{
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
{
sBarAttr.iWidth = Height;
}
else
{
sBarAttr.iWidth = Height + iGuard;
sBarAttr.sCoord.iX -= iGuard;
}
sBarAttr.iHeight = psBarCodeAttr->iNarrow; /* draw bar 01010 */
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
//psBarCodeAttr->sCoord.iY += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow; WRONG!
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
// kcmarkUPCA
if ( psBarCodeAttr->iHuman != 0 || psBarCodeAttr->eLanguage == LANG_ZPL)
sBarAttr.sCoord.iX += iGuard;
sBarAttr.iWidth = Height;
}
break;
}
case 180:
{
for ( k = 0 ; k < 6 ; k++ )
{
for ( i = 0 ; i < 4 ; i++ )
{
sBarAttr.sCoord.iX -= Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
i += 1;
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && k == 0 && j == 0 && i < 2 && psBarCodeAttr->eLanguage != LANG_ZPL)
{
if ( i == 0 )
sBarAttr.sCoord.iY += (iGuard << 1);
else
sBarAttr.sCoord.iY += iGuard;
}
sBarAttr.iWidth = Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
sBarAttr.sCoord.iX -= sBarAttr.iWidth;
DrawBar(&sBarAttr);
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && k == 0 && j == 0 && i < 4 && psBarCodeAttr->eLanguage != LANG_ZPL)
{
if ( i != 1 )
sBarAttr.sCoord.iY -= iGuard;
}
}
if ( j == 0 && k == 0 )
{
sBarAttr.sCoord.iY += iGuard;
sBarAttr.iHeight = Height;
}
else if ( j == 1 && k == 4 )
{
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
{
sBarAttr.iHeight = Height;
}
else
{
sBarAttr.iHeight = Height + iGuard;
sBarAttr.sCoord.iY -= iGuard;
}
}
if ( j == 1 )
{
sBarAttr.sCoord.iX -= Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
}
pValue += 1;
}
if ( j == 0 ) /* center character */
{
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
{
sBarAttr.iHeight = Height;
sBarAttr.sCoord.iY += iGuard;
}
else
{
sBarAttr.iHeight = Height + iGuard;
}
sBarAttr.sCoord.iY -= iGuard;
sBarAttr.iWidth = psBarCodeAttr->iNarrow; /* draw bar 01010 */
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow ;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow;
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.sCoord.iY -= iGuard;
sBarAttr.iHeight = Height;
sBarAttr.sCoord.iY += iGuard;
}
break;
}
case 270:
{
for ( k = 0 ; k < 6 ; k++ )
{
for ( i = 0 ; i < 4 ; i++ )
{
sBarAttr.sCoord.iY -= Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
i += 1;
sBarAttr.iHeight = Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
sBarAttr.sCoord.iY -= Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
}
if ( j == 0 && k == 0 )
{
sBarAttr.iWidth = Height;
}
else if ( j == 1 && k == 4 )
{
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.iWidth = Height;
else
sBarAttr.iWidth = Height + iGuard;
}
if ( j == 1 )
{
sBarAttr.sCoord.iY -= Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
}
pValue += 1;
}
if ( j == 0 ) /* center character */
{
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.iWidth = Height;
else
sBarAttr.iWidth = Height + iGuard;
sBarAttr.iHeight = psBarCodeAttr->iNarrow; /* draw bar 01010 */
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow;
sBarAttr.iWidth = Height;
}
break;
}
}
}
/* STOP character */
switch ( psBarCodeAttr->iRotation )
{
case 0:
{
// sBarAttr.iHeight = Height + iGuard;
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.iHeight = Height;
sBarAttr.iWidth = psBarCodeAttr->iNarrow; /* draw bar 101 */
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
break;
}
case 90:
{
// sBarAttr.iWidth = Height + iGuard;
// sBarAttr.sCoord.iX -= iGuard;
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
{
sBarAttr.iWidth = Height;
//sBarAttr.sCoord.iX += iGuard;
}
sBarAttr.iHeight = psBarCodeAttr->iNarrow; /* draw bar 101 */
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
break;
}
case 180:
{
// sBarAttr.iHeight = Height + iGuard;
// sBarAttr.sCoord.iY -= iGuard;
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
{
sBarAttr.iHeight = Height;
//sBarAttr.sCoord.iY += iGuard;
}
sBarAttr.iWidth = psBarCodeAttr->iNarrow; /* draw bar 101 */
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
break;
}
case 270:
{
// sBarAttr.iWidth = Height + iGuard;
// kcmarkUPCA
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.iWidth = Height;
sBarAttr.iHeight = psBarCodeAttr->iNarrow; /* draw bar 101 */
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
break;
}
}
/* Add on 2 or 5 */
if ( psBarCodeAttr->iCheck == 2 || psBarCodeAttr->iCheck == 5 )
{
iOdd = 0;
iEven = 0;
pValue = aValue;
pHum = aHum;
for ( i = 0 ; i < psBarCodeAttr->iCheck ; i++ )
{
if ( *pText < 48 || *pText > 57 )
return FALSE;
aValue[i] = *pText - 48;
aHum[i] = *pText;
pText += 1;
}
aHum[i] = 0;
if ( psBarCodeAttr->iCheck == 2 )
{
iSum = 10 * aValue[0] + aValue[1];
iCheck = iSum % 4;
}
else
{
iSum = 3 * (aValue[0] + aValue[2] + aValue[4]) +
9 * (aValue[1] + aValue[3]);
iCheck = iSum % 10;
}
switch ( psBarCodeAttr->iRotation )
{
case 0:
{
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow + iAddSpace;
sTextAttr.sCoord.iX = sBarAttr.sCoord.iX + 6 * psBarCodeAttr->iNarrow; // 6 : 1011 + 01
sTextAttr.sCoord.iY = sBarAttr.sCoord.iY;
sBarAttr.sCoord.iY += iAdd;
sBarAttr.iHeight = Height - iAdd;
sBarAttr.iWidth = psBarCodeAttr->iNarrow; /* draw bar 1011 */
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
sBarAttr.iWidth = psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += sBarAttr.iWidth;
break;
}
case 90:
{
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow + iAddSpace;
sTextAttr.sCoord.iX = sBarAttr.sCoord.iX + sBarAttr.iWidth;
sTextAttr.sCoord.iY = sBarAttr.sCoord.iY + 6 * psBarCodeAttr->iNarrow;
// kcmarkUPCA
if ( psBarCodeAttr->iHuman != 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.sCoord.iX += iGuard;
sBarAttr.iWidth = Height - iAdd;
sBarAttr.iHeight = psBarCodeAttr->iNarrow; /* draw bar 1011 */
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
sBarAttr.iHeight = psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += sBarAttr.iHeight;
break;
}
case 180:
{
sBarAttr.sCoord.iX -= iAddSpace;
sTextAttr.sCoord.iX = sBarAttr.sCoord.iX - 6 * psBarCodeAttr->iNarrow;
sTextAttr.sCoord.iY = sBarAttr.sCoord.iY + sBarAttr.iHeight;
// kcmarkUPCA
if ( psBarCodeAttr->iHuman != 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.sCoord.iY += iGuard;
sBarAttr.iHeight = Height - iAdd;
sBarAttr.iWidth = psBarCodeAttr->iNarrow; /* draw bar 1011 */
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
sBarAttr.iWidth = psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
break;
}
case 270:
{
sBarAttr.sCoord.iY -= iAddSpace;
sTextAttr.sCoord.iX = sBarAttr.sCoord.iX;
sTextAttr.sCoord.iY = sBarAttr.sCoord.iY - 6 * psBarCodeAttr->iNarrow;
sBarAttr.sCoord.iX += iAdd;
sBarAttr.iWidth = Height - iAdd;
sBarAttr.iHeight = psBarCodeAttr->iNarrow; /* draw bar 1011 */
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
sBarAttr.iHeight = psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
break;
}
}
if ( psBarCodeAttr->iHuman != 0 )
{
sTextAttr.ExpLength = strlen((CHAR *)pHum);
sTextAttr.pExp = pHum;
OutText(&sTextAttr);
}
switch ( psBarCodeAttr->iRotation )
{
case 0:
{
for ( k = 0 ; k < psBarCodeAttr->iCheck ; k++ )
{
if ( psBarCodeAttr->iCheck == 5 )
{
j = Add5[iCheck][k];
}
else
{
j = Add2[iCheck][k];
}
for ( i = 0 ; i < 4 ; i++ )
{
sBarAttr.sCoord.iX += Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
i += 1;
sBarAttr.iWidth = Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
}
pValue += 1;
if ( k != (psBarCodeAttr->iCheck - 1) ) /* center character */
{
sBarAttr.iWidth = psBarCodeAttr->iNarrow; /* draw bar 01 */
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow;
}
}
break;
}
case 90:
{
for ( k = 0 ; k < psBarCodeAttr->iCheck ; k++ )
{
if ( psBarCodeAttr->iCheck == 5 )
{
j = Add5[iCheck][k];
}
else
{
j = Add2[iCheck][k];
}
for ( i = 0 ; i < 4 ; i++ )
{
sBarAttr.sCoord.iY += Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
i += 1;
sBarAttr.iHeight = Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
}
pValue += 1;
if ( k != (psBarCodeAttr->iCheck - 1 ) ) /* center character */
{
sBarAttr.iHeight = psBarCodeAttr->iNarrow; /* draw bar 01 */
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow;
}
}
break;
}
case 180:
{
for ( k = 0 ; k < psBarCodeAttr->iCheck ; k++ )
{
if ( psBarCodeAttr->iCheck == 5 )
{
j = Add5[iCheck][k];
}
else
{
j = Add2[iCheck][k];
}
for ( i = 0 ; i < 4 ; i++ )
{
sBarAttr.sCoord.iX -= Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
i += 1;
sBarAttr.iWidth = Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
sBarAttr.sCoord.iX -= sBarAttr.iWidth;
DrawBar(&sBarAttr);
}
pValue += 1;
if ( k != (psBarCodeAttr->iCheck - 1) ) /* center character */
{
sBarAttr.iWidth = psBarCodeAttr->iNarrow; /* draw bar 01 */
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow ;
DrawBar(&sBarAttr);
}
}
break;
}
case 270:
{
for ( k = 0 ; k < psBarCodeAttr->iCheck ; k++ )
{
if ( psBarCodeAttr->iCheck == 5 )
{
j = Add5[iCheck][k];
}
else
{
j = Add2[iCheck][k];
}
for ( i = 0 ; i < 4 ; i++ )
{
sBarAttr.sCoord.iY -= Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
i += 1;
sBarAttr.iHeight = Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
sBarAttr.sCoord.iY -= Chara[j][*pValue][i] * psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
}
pValue += 1;
if ( k != ( psBarCodeAttr->iCheck - 1 ) ) /* center character */
{
sBarAttr.iHeight = psBarCodeAttr->iNarrow; /* draw bar 01 */
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
}
}
break;
}
}
}
psBarCodeAttr->TotalWidth = psBarCodeAttr->iNarrow * 95 + QUIET_MU;
psBarCodeAttr->TotalHeight = psBarCodeAttr->iHeight;
return TRUE;
}
INT PreviewUpca(_BarCodeAttr *psBarCodeAttr)
{
psBarCodeAttr->TotalWidth = psBarCodeAttr->iNarrow * 95 + QUIET_MU;
psBarCodeAttr->TotalHeight = psBarCodeAttr->iHeight;
return TRUE;
}