/******************************************************************************
* *
* M O D U L E D E F I N E *
* *
******************************************************************************/
#define UPCE_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 13 // (6 + 1 + 5 + 1)
#define UPCE_STR_LEN 6
/******************************************************************************
* *
* 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[2][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,
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 Check[10][6] =
{
1,1,1,0,0,0,
1,1,0,1,0,0,
1,1,0,0,1,0,
1,1,0,0,0,1,
1,0,1,1,0,0,
1,0,0,1,1,0,
1,0,0,0,1,1,
1,0,1,0,1,0,
1,0,1,0,0,1,
1,0,0,1,0,1
};
CONST STATIC BYTE Add2[4][2] =
{
0,0,
0,1,
1,0,
1,1
};
CONST STATIC BYTE Add5[10][5] =
{
1,1,0,0,0,
1,0,1,0,0,
1,0,0,1,0,
1,0,0,0,1,
0,1,1,0,0,
0,0,1,1,0,
0,0,0,1,1,
0,1,0,1,0,
0,1,0,0,1,
0,0,1,0,1
};
/******************************************************************************
* *
* 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 RecognizeUpce(BYTE *Target, BYTE *Source, INT MaxLen)
{
INT Length;
INT TOffset;
Length = strlen((CHAR *)Source);
TOffset = 0;
if ( Length == 10 )
{
// if manufacture code last 1 != 0 target => first 5 + last 1
if (*( Source + 4 ) != '0' )
{
strncpy( (CHAR *)Target, (CHAR *)Source, MaxLen - 1);
*( Target + MaxLen - 1) = *( Source + Length - 1);
}
else
{
// if manufacture code last 2 != 0 target => first 4 + last 1
if ( *( Source + 3 ) != '0' )
{
strncpy( (CHAR *)Target, (CHAR *)Source, 4);
strncpy( (CHAR *)( Target + 4 ), (CHAR *)( Source + Length - 1), 1);
*(Target + 5) = '4';
}
// if manufacture code last 3 = 000, 100, 200 => first 2 + last 3
else if ( *(Source + 2 ) == '0' || *(Source + 2 ) == '1' || *(Source + 2 ) == '2')
{
strncpy( (CHAR *)Target, (CHAR *)Source, 2);
strncpy( (CHAR *)( Target + 2 ), (CHAR *)( Source + Length - 3), 3);
*(Target + 5) = *(Source + 2 );
}
// if manufacture code last 3 = 300 ~ 900 => first 3 + last 2
else
{
strncpy( (CHAR *)Target, (CHAR *)Source, 3);
strncpy( (CHAR *)( Target + 3 ), (CHAR *)( Source + Length - 2), 2);
*(Target + 5) = '3';
}
}
*( Target + MaxLen ) = '\0';
}
else
{
if ( Length <= MaxLen )
{
if ( Length < MaxLen )
memset(Target, '0', MaxLen - Length);
TOffset = MaxLen - Length;
while ( TOffset < MaxLen )
{
if ( isdigit( *Source ) )
*( Target + TOffset ) = *Source;
else
*( Target + TOffset ) = '0';
Source += 1;
TOffset += 1;
}
*( Target + TOffset ) = '\0';
}
else if ( Length > MaxLen )
{
strncpy( (CHAR *)Target, (CHAR *)Source, MaxLen - 1);
*( Target + MaxLen - 1) = *( Source + Length - 1);
*( Target + MaxLen ) = '\0';
}
}
}
INT Upce(_BarCodeAttr *psBarCodeAttr)
{
_BarAttr sBarAttr;
_TextAttr sTextAttr;
BYTE aValue[13], aHum[13], aString[7], *pValue, *pHum, *pText;
BYTE TargetStr[13];
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 )
RecognizeUpce(TargetStr, psBarCodeAttr->pExp, UPCE_STR_LEN + 2);
else if ( psBarCodeAttr->iCheck == 5 )
RecognizeUpce(TargetStr, psBarCodeAttr->pExp, UPCE_STR_LEN + 5);
else
RecognizeUpce(TargetStr, psBarCodeAttr->pExp, UPCE_STR_LEN );
pText = TargetStr;
}
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 || psBarCodeAttr->eLanguage == LANG_ZPL)
Height -= iGuard;
#endif
for ( i = 0 ; i < 6 ; i++ ) // The total character need 6 number
{
if ( *pText < '0' || *pText > '9' )
return FALSE;
*pHum = *pText;
*pValue = *pText - '0';
pHum += 1;
pValue += 1;
pText += 1;
}
if (psBarCodeAttr->eLanguage == LANG_EPL)
{
if (psBarCodeAttr->iCheck == 2 && strlen((CHAR *)psBarCodeAttr->pExp) > UPCE_STR_LEN + 2)
pText += 1;
if (psBarCodeAttr->iCheck == 5 && strlen((CHAR *)psBarCodeAttr->pExp) > UPCE_STR_LEN + 5)
pText += 1;
}
// if ( (*pText == 0 && ( psBarCodeAttr->iCheck != 2 || psBarCodeAttr->iCheck != 5 )) ||
// (*pText > 47 && *pText < 58 && ( psBarCodeAttr->iCheck == 2 || psBarCodeAttr->iCheck == 5 )) )
if ( aValue[5] == 0 || aValue[5] == 1 || aValue[5] == 2 )
{
iOdd = aValue[1] + aValue[2] + aValue[4];
iEven = aValue[0] + aValue[5] + aValue[3];
}
else if ( aValue[5] == 3 )
{
iOdd = aValue[1] + aValue[4];
iEven = aValue[0] + aValue[2] + aValue[3];
}
else if ( aValue[5] == 4 )
{
iOdd = aValue[1] + aValue[3] + aValue[4];
iEven = aValue[0] + aValue[2];
}
else /* if ( aValue == 5 || aValue == 6 || aValue == 7
|| aValue == 8 || aValue == 9 ) */
{
iOdd = aValue[1] + aValue[3] + aValue[5];
iEven = aValue[0] + aValue[2] + aValue[4];
}
iSum = iOdd * 3 + iEven;
iCheck = 10 - iSum % 10;
if ( iCheck == 10 )
iCheck = 0;
/* *pValue = (BYTE)iCheck; */
aHum[6] = (BYTE)iCheck + '0';
aHum[7] = 0;
/* START character */
switch ( psBarCodeAttr->iRotation )
{
case 0:
{
// kcmarkUPCE
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:
{
// kcmarkUPCE
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;
// kcmarkUPCE
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:
{
// kcmarkUPCE
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);
// kcmarkUPCE
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:
{
// kcmarkUPCE
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;
// fn_debug
sTextAttr.iDirection = psBarCodeAttr->iRotation;
sTextAttr.iRotation = psBarCodeAttr->iRotation;
sTextAttr.iDistance = 0;
sTextAttr.iHoriMulti = psBarCodeAttr->FontHoriMulti;
sTextAttr.iVertMulti = psBarCodeAttr->FontVertMulti;
*aString = '0';
*(aString + 1) = 0;
sTextAttr.ExpLength = strlen((CHAR *)aString);
sTextAttr.pExp = aString;
OutText(&sTextAttr);
switch ( psBarCodeAttr->iRotation )
{
case 0:
sTextAttr.sCoord.iX += (7 + 3) * psBarCodeAttr->iNarrow;
break;
case 90:
sTextAttr.sCoord.iY += (7 + 3) * psBarCodeAttr->iNarrow;
break;
case 180:
sTextAttr.sCoord.iX -= (7 + 3) * psBarCodeAttr->iNarrow;
break;
case 270:
sTextAttr.sCoord.iY -= (7 + 3) * psBarCodeAttr->iNarrow;
break;
}
for ( i = 0 ; i < 6 ; 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 + 6) * psBarCodeAttr->iNarrow;
break;
case 90:
sTextAttr.sCoord.iY += (6 * 7 + 6) * psBarCodeAttr->iNarrow;
break;
case 180:
sTextAttr.sCoord.iX -= (6 * 7 + 6) * psBarCodeAttr->iNarrow;
break;
case 270:
sTextAttr.sCoord.iY -= (6 * 7 + 6) * psBarCodeAttr->iNarrow;
break;
}
*aString = *pHum;
*(aString + 1) = 0;
sTextAttr.ExpLength = strlen((CHAR *)aString);
sTextAttr.pExp = aString;
OutText(&sTextAttr);
}
switch ( psBarCodeAttr->iRotation )
{
case 0:
{
for ( k = 0 ; k < 6 ; k++ )
{
j = Check[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;
}
break;
}
case 90:
{
for ( k = 0 ; k < 6 ; k++ )
{
j = Check[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;
}
break;
}
case 180:
{
for ( k = 0 ; k < 6 ; k++ )
{
j = Check[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;
}
break;
}
case 270:
{
for ( k = 0 ; k < 6 ; k++ )
{
j = Check[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;
}
break;
}
}
/* STOP character */
switch ( psBarCodeAttr->iRotation )
{
case 0:
{
// kcmarkUPCE
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.iHeight = Height;
else
sBarAttr.iHeight = Height + iGuard;
sBarAttr.iWidth = psBarCodeAttr->iNarrow; /* draw bar 010101 */
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
break;
}
case 90:
{
// kcmarkUPCE
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 010101 */
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY += psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
break;
}
case 180:
{
// kcmarkUPCE
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
{
sBarAttr.iHeight = Height;
}
else
{
sBarAttr.iHeight = Height + iGuard;
sBarAttr.sCoord.iY -= iGuard;
}
sBarAttr.iWidth = psBarCodeAttr->iNarrow; /* draw bar 010101 */
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iX -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
break;
}
case 270:
{
// kcmarkUPCE
if ( psBarCodeAttr->iHuman == 0 && psBarCodeAttr->eLanguage != LANG_ZPL)
sBarAttr.iWidth = Height;
else
sBarAttr.iWidth = Height + iGuard;
sBarAttr.iHeight = psBarCodeAttr->iNarrow; /* draw bar 010101 */
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow + psBarCodeAttr->iNarrow;
DrawBar(&sBarAttr);
sBarAttr.sCoord.iY -= psBarCodeAttr->iNarrow + 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;
// kcmarkUPCE
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;
// kcmarkUPCE
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 * 52 + QUIET_MU;
psBarCodeAttr->TotalHeight = psBarCodeAttr->iHeight;
return TRUE;
}
INT PreviewUpce(_BarCodeAttr *psBarCodeAttr)
{
psBarCodeAttr->TotalWidth = psBarCodeAttr->iNarrow * 52 + QUIET_MU;
psBarCodeAttr->TotalHeight = psBarCodeAttr->iHeight;
return TRUE;
}