2010-11-11 21:30 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)

* harbour/contrib/hbzebra/hbzebra.ch
  * harbour/contrib/hbzebra/hbzebra.h
  * harbour/contrib/hbzebra/hbzebra.hbp
  + harbour/contrib/hbzebra/pdf417.c
    + added two-dimensional PDF417 barcode support
      HB_ZEBRA_PDF417( cData, [ nFlags ] [, nDataColumns ] ) --> hZebra

    ; This requires testing on real scanners. F.e., some internet online 
      PDF417 decoders does not allow encoding mode switching from numeric 
      to text. Though I see no reason to be this prohibited by 
      specification.

  * harbour/contrib/hbzebra/drawcore.c
    + implemented 2D barcode drawing
    * changed argument error logic to generate RTE from Harbour level

  * harbour/contrib/hbzebra/testcair.prg
  * harbour/contrib/hbzebra/testhpdf.prg
  * harbour/contrib/hbzebra/testwin.prg
    * included new barcode into test samples
This commit is contained in:
Mindaugas Kavaliauskas
2010-11-11 19:32:33 +00:00
parent 1e05221ec9
commit 2118caf5be
9 changed files with 1478 additions and 20 deletions

View File

@@ -16,6 +16,28 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-11-11 21:30 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
* harbour/contrib/hbzebra/hbzebra.ch
* harbour/contrib/hbzebra/hbzebra.h
* harbour/contrib/hbzebra/hbzebra.hbp
+ harbour/contrib/hbzebra/pdf417.c
+ added two-dimensional PDF417 barcode support
HB_ZEBRA_PDF417( cData, [ nFlags ] [, nDataColumns ] ) --> hZebra
; This requires testing on real scanners. F.e., some internet online
PDF417 decoders does not allow encoding mode switching from numeric
to text. Though I see no reason to be this prohibited by
specification.
* harbour/contrib/hbzebra/drawcore.c
+ implemented 2D barcode drawing
* changed argument error logic to generate RTE from Harbour level
* harbour/contrib/hbzebra/testcair.prg
* harbour/contrib/hbzebra/testhpdf.prg
* harbour/contrib/hbzebra/testwin.prg
* included new barcode into test samples
2010-11-10 22:47 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbwin/tests/testcom1.prg
* contrib/hbwin/tests/testcom2.prg

View File

@@ -61,20 +61,19 @@ int hb_zebra_draw( PHB_ZEBRA pZebra, HB_ZEBRA_CALLBACK pCallback, void * cargo,
double dLast;
HB_SIZE n, nLen, nCount;
HB_BOOL fBit, fLastBit;
int i, iCol = pZebra->iCol;
HB_SYMBOL_UNUSED( iFlags );
if( pZebra->iError != 0 )
return HB_ZEBRA_ERROR_INVALIDZEBRA;
if( ! pCallback )
return HB_ZEBRA_ERROR_ARGUMENT;
nLen = hb_bitbuffer_len( pZebra->pBits );
fLastBit = hb_bitbuffer_get( pZebra->pBits, 0 );
dLast = dX;
nCount = 1;
for( n = 1; n < nLen; n++ )
nCount = 0;
i = 0;
for( n = 0; n < nLen; n++ )
{
fBit = hb_bitbuffer_get( pZebra->pBits, n );
if( fBit != fLastBit )
@@ -87,8 +86,22 @@ int hb_zebra_draw( PHB_ZEBRA pZebra, HB_ZEBRA_CALLBACK pCallback, void * cargo,
fLastBit = fBit;
}
nCount++;
if( ++i == iCol )
{
if( nCount )
{
if( fBit )
pCallback( cargo, dLast, dY, dWidth * nCount, dHeight );
nCount = 0;
}
i = 0;
dY += dHeight;
dLast = dX;
if( n + 1 < nLen )
fLastBit = hb_bitbuffer_get( pZebra->pBits, n + 1 );
}
}
if( fLastBit )
if( fLastBit && nCount )
pCallback( cargo, dLast, dY, dWidth * nCount, dHeight );
return 0;
@@ -111,9 +124,6 @@ static void hb_zebra_draw_codeblock_callback( void * pDrawBlock, double dX, doub
int hb_zebra_draw_codeblock( PHB_ZEBRA pZebra, PHB_ITEM pDrawBlock, double dX, double dY, double dWidth, double dHeight, int iFlags )
{
if( ! pDrawBlock || ! HB_IS_BLOCK( pDrawBlock ) )
return HB_ZEBRA_ERROR_ARGUMENT;
return hb_zebra_draw( pZebra, hb_zebra_draw_codeblock_callback, pDrawBlock, dX, dY, dWidth, dHeight, iFlags );
}
@@ -125,5 +135,7 @@ HB_FUNC( HB_ZEBRA_DRAW )
PHB_ITEM pDrawBlock = hb_param( 2, HB_IT_BLOCK );
if( pDrawBlock )
hb_retni( hb_zebra_draw_codeblock( pZebra, pDrawBlock, hb_parnd( 3 ), hb_parnd( 4 ), hb_parnd( 5 ), hb_parnd( 6 ), hb_parni( 7 ) ) );
else
hb_errRT_BASE( EG_ARG, 3012, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
}
}

View File

@@ -68,13 +68,16 @@
#define HB_ZEBRA_TYPE_ITF 10
#define HB_ZEBRA_TYPE_MSI 11
#define HB_ZEBRA_TYPE_PDF417 257
/* Generate errors */
#define HB_ZEBRA_ERROR_INVALIDCODE 1
#define HB_ZEBRA_ERROR_BADCHECKSUM 2
#define HB_ZEBRA_ERROR_TOOLARGE 3
#define HB_ZEBRA_ERROR_ARGUMENT 4
/* Draw errors */
#define HB_ZEBRA_ERROR_INVALIDZEBRA 101
#define HB_ZEBRA_ERROR_ARGUMENT 102
/* Generate flags */
#define HB_ZEBRA_FLAG_CHECKSUM 1
@@ -84,6 +87,17 @@
/* Draw flags */
/* Barcode dependent options >= 0x100 */
/* Barcode dependent flags */
#define HB_ZEBRA_FLAG_PDF417_TRUNCATED 0x0100
#define HB_ZEBRA_FLAG_PDF417_LEVEL_MASK 0xF000
#define HB_ZEBRA_FLAG_PDF417_LEVEL0 0x1000
#define HB_ZEBRA_FLAG_PDF417_LEVEL1 0x2000
#define HB_ZEBRA_FLAG_PDF417_LEVEL2 0x3000
#define HB_ZEBRA_FLAG_PDF417_LEVEL3 0x4000
#define HB_ZEBRA_FLAG_PDF417_LEVEL4 0x5000
#define HB_ZEBRA_FLAG_PDF417_LEVEL5 0x6000
#define HB_ZEBRA_FLAG_PDF417_LEVEL6 0x7000
#define HB_ZEBRA_FLAG_PDF417_LEVEL7 0x8000
#define HB_ZEBRA_FLAG_PDF417_LEVEL8 0x9000
#endif /* HB_ZEBRA_CH_ */

View File

@@ -68,6 +68,7 @@ typedef struct
{
int iType;
int iError;
int iCol;
char * szCode;
PHB_BITBUFFER pBits;
} HB_ZEBRA, * PHB_ZEBRA;

View File

@@ -23,6 +23,7 @@ code93.c
eanupc.c
itf.c
msi.c
pdf417.c
# Drawing backends

File diff suppressed because it is too large Load Diff

View File

@@ -39,6 +39,7 @@ PROCEDURE main()
DrawBarcode( hCairo, 400, 1, "CODE128", "Code 128")
DrawBarcode( hCairo, 420, 1, "CODE128", "1234567890")
DrawBarcode( hCairo, 440, 1, "CODE128", "Wikipedia")
DrawBarcode( hCairo, 460, 1, "PDF417", "Hello, World of Harbour!!! It's 2D barcode PDF417 :)" )
cairo_destroy( hCairo )
cairo_surface_write_to_png( hSurface, "testcair.png" )
@@ -47,7 +48,8 @@ PROCEDURE main()
PROCEDURE DrawBarcode( hCairo, nY, nLineWidth, cType, cCode, nFlags )
LOCAL hZebra
LOCAL hZebra, nLineHeight
IF cType == "EAN13"
hZebra := hb_zebra_create_ean13( cCode, nFlags )
ELSEIF cType == "EAN8"
@@ -70,14 +72,20 @@ PROCEDURE DrawBarcode( hCairo, nY, nLineWidth, cType, cCode, nFlags )
hZebra := hb_zebra_create_code11( cCode, nFlags )
ELSEIF cType == "CODE128"
hZebra := hb_zebra_create_code128( cCode, nFlags )
ELSEIF cType == "PDF417"
hZebra := hb_zebra_create_pdf417( cCode, nFlags )
nLineHeight := nLineWidth * 3
ENDIF
IF hZebra != NIL
IF hb_zebra_geterror( hZebra ) == 0
IF EMPTY( nLineHeight )
nLineHeight := 16
ENDIF
cairo_move_to( hCairo, 40, nY + 13 )
cairo_show_text( hCairo, cType )
cairo_move_to( hCairo, 100, nY + 13 )
cairo_show_text( hCairo, hb_zebra_getcode( hZebra ) )
hb_zebra_draw_cairo( hZebra, hCairo, 220, nY, nLineWidth, 16 )
hb_zebra_draw_cairo( hZebra, hCairo, 220, nY, nLineWidth, nLineHeight )
ELSE
? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )
ENDIF

View File

@@ -44,13 +44,14 @@ PROCEDURE Main()
DrawBarcode( page, 400, 1, "CODE128", "Code 128")
DrawBarcode( page, 420, 1, "CODE128", "1234567890")
DrawBarcode( page, 440, 1, "CODE128", "Wikipedia")
DrawBarcode( page, 460, 1, "PDF417", "Hello, World of Harbour!!! It's 2D barcode PDF417 :)" )
? HPDF_SaveToFile( pdf, "testhpdf.pdf" )
RETURN
PROCEDURE DrawBarcode( page, nY, nLineWidth, cType, cCode, nFlags )
LOCAL hZebra
LOCAL hZebra, nLineHeight
SWITCH cType
CASE "EAN13" ; hZebra := hb_zebra_create_ean13( cCode, nFlags ) ; EXIT
@@ -64,15 +65,19 @@ PROCEDURE DrawBarcode( page, nY, nLineWidth, cType, cCode, nFlags )
CASE "CODE93" ; hZebra := hb_zebra_create_code93( cCode, nFlags ) ; EXIT
CASE "CODE11" ; hZebra := hb_zebra_create_code11( cCode, nFlags ) ; EXIT
CASE "CODE128" ; hZebra := hb_zebra_create_code128( cCode, nFlags ) ; EXIT
CASE "PDF417" ; hZebra := hb_zebra_create_pdf417( cCode, nFlags ); nLineHeight := nLineWidth * 3; EXIT
ENDSWITCH
IF hZebra != NIL
IF hb_zebra_geterror( hZebra ) == 0
IF EMPTY( nLineHeight )
nLineHeight := 16
ENDIF
HPDF_Page_BeginText( page )
HPDF_Page_TextOut( page, 40, nY, cType )
HPDF_Page_TextOut( page, 150, nY, hb_zebra_getcode( hZebra ) )
HPDF_Page_EndText( page )
hb_zebra_draw_hpdf( hZebra, page, 300, nY, nLineWidth, 16 )
hb_zebra_draw_hpdf( hZebra, page, 300, nY, nLineWidth, nLineHeight )
ELSE
? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )
ENDIF

View File

@@ -72,6 +72,7 @@ PROCEDURE Main()
DrawBarcode( hDC, 400, 1, "CODE128", "Code 128")
DrawBarcode( hDC, 420, 1, "CODE128", "1234567890")
DrawBarcode( hDC, 440, 1, "CODE128", "Wikipedia")
DrawBarcode( hDC, 460, 1, "PDF417", "Hello, World of Harbour!!! It's 2D barcode PDF417 :)" )
wapi_EndPage( hDC )
ENDIF
@@ -84,10 +85,7 @@ PROCEDURE Main()
#define _SCALE_ 7.2
PROCEDURE DrawBarcode( hDC, nY, nLineWidth, cType, cCode, nFlags )
LOCAL hZebra
nY *= _SCALE_
nLineWidth *= _SCALE_
LOCAL hZebra, nLineHeight
SWITCH cType
CASE "EAN13" ; hZebra := hb_zebra_create_ean13( cCode, nFlags ) ; EXIT
@@ -101,13 +99,20 @@ PROCEDURE DrawBarcode( hDC, nY, nLineWidth, cType, cCode, nFlags )
CASE "CODE93" ; hZebra := hb_zebra_create_code93( cCode, nFlags ) ; EXIT
CASE "CODE11" ; hZebra := hb_zebra_create_code11( cCode, nFlags ) ; EXIT
CASE "CODE128" ; hZebra := hb_zebra_create_code128( cCode, nFlags ) ; EXIT
CASE "PDF417" ; hZebra := hb_zebra_create_pdf417( cCode, nFlags ); nLineHeight := nLineWidth * 3; EXIT
ENDSWITCH
nY *= _SCALE_
nLineWidth *= _SCALE_
IF hZebra != NIL
IF hb_zebra_geterror( hZebra ) == 0
IF EMPTY( nLineHeight )
nLineHeight := 16
ENDIF
wapi_TextOut( hDC, 40 * _SCALE_, nY, cType )
wapi_TextOut( hDC, 150 * _SCALE_, nY, hb_zebra_getcode( hZebra ) )
hb_zebra_draw_wapi( hZebra, hDC, wapi_CreateSolidBrush( 0 ), 300 * _SCALE_, nY, nLineWidth, 16 * _SCALE_ )
hb_zebra_draw_wapi( hZebra, hDC, wapi_CreateSolidBrush( 0 ), 300 * _SCALE_, nY, nLineWidth, nLineHeight * _SCALE_ )
ELSE
? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )
ENDIF