2010-11-11 22:44 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbzebra/coredraw.c
    + Added protection against NULL pCallback pointer.

  * contrib/hbzebra/tests/testwin.prg
  * contrib/hbzebra/tests/testcair.prg
  * contrib/hbzebra/tests/testhpdf.prg
    * Minor formatting.

  - contrib/hbzebra/d_cairo.c
  * contrib/hbzebra/hbzebra.hbp
    - Deleted cairo specific backend.
This commit is contained in:
Viktor Szakats
2010-11-11 21:45:36 +00:00
parent bfa4a7496d
commit a8a6533a18
7 changed files with 26 additions and 139 deletions

View File

@@ -16,8 +16,21 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-11-11 22:44 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbzebra/coredraw.c
+ Added protection against NULL pCallback pointer.
* contrib/hbzebra/tests/testwin.prg
* contrib/hbzebra/tests/testcair.prg
* contrib/hbzebra/tests/testhpdf.prg
* Minor formatting.
- contrib/hbzebra/d_cairo.c
* contrib/hbzebra/hbzebra.hbp
- Deleted cairo specific backend.
2010-11-11 23:05 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
* harbour/contrib/hbzebra/drawcore.c
* harbour/contrib/hbzebra/coredraw.c
! added missing include
* harbour/ChangeLog
! fixed error in previous commit log
@@ -30,12 +43,12 @@
+ added two-dimensional PDF417 barcode support
HB_ZEBRA_CREATE_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
; 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
* harbour/contrib/hbzebra/coredraw.c
+ implemented 2D barcode drawing
* changed argument error logic to generate RTE from Harbour level
@@ -84,7 +97,7 @@
- contrib/hbzebra/d_win.c
- contrib/hbzebra/d_hpdf.c
- Deleted specialized drawing backend from HBZEBRA.
; TODO: Delete also cairo backend.
; TODO: Delete also cairo backend. [DONE]
2010-11-10 18:21 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbzebra/code39.c

View File

@@ -79,7 +79,7 @@ int hb_zebra_draw( PHB_ZEBRA pZebra, HB_ZEBRA_CALLBACK pCallback, void * cargo,
fBit = hb_bitbuffer_get( pZebra->pBits, n );
if( fBit != fLastBit )
{
if( fLastBit )
if( fLastBit && pCallback )
pCallback( cargo, dLast, dY, dWidth * nCount, dHeight );
dLast += dWidth * nCount;
@@ -91,7 +91,7 @@ int hb_zebra_draw( PHB_ZEBRA pZebra, HB_ZEBRA_CALLBACK pCallback, void * cargo,
{
if( nCount )
{
if( fBit )
if( fBit && pCallback )
pCallback( cargo, dLast, dY, dWidth * nCount, dHeight );
nCount = 0;
}
@@ -102,7 +102,7 @@ int hb_zebra_draw( PHB_ZEBRA pZebra, HB_ZEBRA_CALLBACK pCallback, void * cargo,
fLastBit = hb_bitbuffer_get( pZebra->pBits, n + 1 );
}
}
if( fLastBit && nCount )
if( fLastBit && nCount && pCallback )
pCallback( cargo, dLast, dY, dWidth * nCount, dHeight );
return 0;

View File

@@ -1,110 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Zebra barcode library
*
* Copyright 2010 Mindaugas Kavaliauskas <dbtopas at dbtopas.lt>
* www - http://harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#include "hbzebra.h"
#include "hbcairo.h"
int hb_zebra_draw_cairo( PHB_ZEBRA pZebra, cairo_t * pCairo, double dX, double dY, double dWidth, double dHeight, int iFlags )
{
double dLast;
HB_SIZE n, nLen, nCount;
HB_BOOL fBit, fLastBit;
HB_SYMBOL_UNUSED( iFlags );
if( pZebra->iError != 0 )
return HB_ZEBRA_ERROR_INVALIDZEBRA;
cairo_save( pCairo );
nLen = hb_bitbuffer_len( pZebra->pBits );
fLastBit = hb_bitbuffer_get( pZebra->pBits, 0 );
dLast = dX;
nCount = 1;
for( n = 1; n < nLen; n++ )
{
fBit = hb_bitbuffer_get( pZebra->pBits, n );
if( fBit != fLastBit )
{
if( fLastBit )
{
cairo_rectangle( pCairo, dLast, dY, dWidth * nCount, dHeight );
cairo_fill( pCairo );
}
dLast += dWidth * nCount;
nCount = 0;
fLastBit = fBit;
}
nCount++;
}
if( fLastBit )
{
cairo_rectangle( pCairo, dLast, dY, dWidth * nCount, dHeight );
cairo_fill( pCairo );
}
cairo_restore( pCairo );
return 0;
}
HB_FUNC( HB_ZEBRA_DRAW_CAIRO )
{
PHB_ZEBRA pZebra = hb_zebra_param( 1 );
if( pZebra )
{
cairo_t * pCairo = hb_cairo_param( 2 );
if( pCairo )
{
hb_retni( hb_zebra_draw_cairo( pZebra, pCairo, hb_parnd( 3 ), hb_parnd( 4 ), hb_parnd( 5 ), hb_parnd( 6 ), hb_parni( 7 ) ) );
}
}
}

View File

@@ -13,6 +13,7 @@
# Core
core.c
coredraw.c
# Barcodes
codabar.c
@@ -24,20 +25,3 @@ eanupc.c
itf.c
msi.c
pdf417.c
# Drawing backends
-depoptional=cairo:yes
-depkeyhead=cairo:cairo.h
-depcontrol=cairo:no{HB_BUILD_3RDEXT='no'}
-depcontrol=cairo:${HB_WITH_CAIRO}
-depincpath=cairo:/usr/include/cairo
-depincpath=cairo:/opt/local/include/cairo
-depimplibs=cairo:../../bin/libcairo-2.dll
-depimplibd=cairo:cairo
-depfinish=cairo
coredraw.c
{HBMK_HAS_CAIRO}d_cairo.c
{HBMK_HAS_CAIRO}../hbcairo/hbcairo.hbc

View File

@@ -87,7 +87,7 @@ PROCEDURE DrawBarcode( hCairo, nY, nLineWidth, cType, cCode, nFlags )
cairo_show_text( hCairo, hb_zebra_getcode( hZebra ) )
hb_zebra_draw_cairo( hZebra, hCairo, 220, nY, nLineWidth, nLineHeight )
ELSE
? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )
? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )
ENDIF
hb_zebra_destroy( hZebra )
ELSE

View File

@@ -79,7 +79,7 @@ PROCEDURE DrawBarcode( page, nY, nLineWidth, cType, cCode, nFlags )
HPDF_Page_EndText( page )
hb_zebra_draw_hpdf( hZebra, page, 300, nY, nLineWidth, nLineHeight )
ELSE
? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )
? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )
ENDIF
hb_zebra_destroy( hZebra )
ELSE

View File

@@ -114,7 +114,7 @@ PROCEDURE DrawBarcode( hDC, nY, nLineWidth, cType, cCode, nFlags )
wapi_TextOut( hDC, 150 * _SCALE_, nY, hb_zebra_getcode( hZebra ) )
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 )
? "Type", cType, "Code", cCode, "Error", hb_zebra_geterror( hZebra )
ENDIF
hb_zebra_destroy( hZebra )
ELSE