Somebody knows how to print rectangular Data Matrix barcode? I tried with hbzebra and it works for square Data Matrix code. I don't understand how to get rectangular code without stretching the code itself.
EMG
#include "Fivewin.ch"
#define HB_ZEBRA_FLAG_DATAMATRIX_RECTANGLE 0x0200
FUNCTION MAIN()
LOCAL oPrn
PRINT oPrn PREVIEW
PAGE
DATAMATRIX( oPrn, "12345678901234567890123456789012345678901234567890", 1000, 1000, HB_ZEBRA_FLAG_DATAMATRIX_RECTANGLE )
ENDPAGE
ENDPRINT
RETURN NIL
FUNCTION DATAMATRIX( oPrn, cCod, nWidth, nHeight, nFlags )
LOCAL hDCDesk := GETDC( GETDESKTOPWINDOW() )
LOCAL hDCMem := CREATECOMPATIBLEDC( hDCDesk )
LOCAL hBrush := CREATESOLIDBRUSH( 0 )
LOCAL hBack := CREATESOLIDBRUSH( CLR_WHITE )
LOCAL hBmp := CREATECOMPATIBLEBITMAP( hDCDesk, nWidth, nHeight )
LOCAL hBmpOld := SELECTOBJECT( hDCMem, hBmp )
LOCAL hZebra := HB_ZEBRA_CREATE_DATAMATRIX( cCod, nFlags )
LOCAL hDib
FILLRECT( hDCMem, { 0, 0, nHeight, nWidth }, hBack )
HB_ZEBRA_DRAW( hZebra, { | x, y, w, h | FillRect( hDCMem, { y, x, y + h, x + w }, hBrush ) }, 0, 0, 20, 20 )
hDib = DIBFROMBITMAP( hBmp )
DIBDRAW( oPrn:hDCOut, hDib, , 500, 500 )
GLOBALFREE( hDib )
SELECTOBJECT( hDCMem, hBmpOld )
DELETEOBJECT( hBrush )
DELETEOBJECT( hBack )
HB_ZEBRA_DESTROY( hZebra )
DELETEOBJECT( hBmp )
DELETEDC( hDCMem )
RELEASEDC( GETDESKTOPWINDOW(), hDCDesk )
RETURN NIL
#include "Fivewin.ch"
#define HB_ZEBRA_FLAG_DATAMATRIX_RECTANGLE 0x0200
FUNCTION MAIN()
LOCAL oPrn, cText
// Original by Enrico,
// cText := "12345678901234567890123456789012345678901234567890"
// cText := MemoRead( ".\QRCODE.TXT" )
// Asi, no funciona.
cText := "35141146377222003730599000004630001158179941|20141105134922|10.00|61694805808|m+4o8FY1lig1zcy6VU3t7INVwE6kiA/ykLXKDFZfb9gu0g4wl3Fk2HYaRhSt8G+yk9mP/R65m3R7V2IO8CxnmO1oVtlamB6UKA+UZZqDNEqtYlhQzLySNzMG0thaNMZsq5RxmQ3eQLPw8LLez3MqWvUveFXNSSq6AGEX2+KOdavteo3K2L06SQoVIjwkmcgRzqhfHP3y8t2wfr1nw/WAnaCF9ZY/K4dTykk3hsXcan/MKCTBlcSOhNgSh3sdsQHpl2w2tmbLBsYBLFkuvKlwzHarNJQ1RfRznGdojHglQH1KVtbAUXKke54pdRt3JL7nJlR+Lbmtd2tjcT2vRyTepw=="
PRINT oPrn PREVIEW MODAL
PAGE
DATAMATRIX( oPrn, cText, 1000, 1000, HB_ZEBRA_FLAG_DATAMATRIX_RECTANGLE )
ENDPAGE
ENDPRINT
RETURN NIL
FUNCTION DATAMATRIX( oPrn, cCod, nWidth, nHeight, nFlags )
LOCAL hDCDesk := GETDC( GETDESKTOPWINDOW() )
LOCAL hDCMem := CREATECOMPATIBLEDC( hDCDesk )
LOCAL hBrush := CREATESOLIDBRUSH( 0 )
LOCAL hBack := CREATESOLIDBRUSH( CLR_WHITE )
LOCAL hBmp := CREATECOMPATIBLEBITMAP( hDCDesk, nWidth, nHeight )
LOCAL hBmpOld := SELECTOBJECT( hDCMem, hBmp )
LOCAL hZebra := HB_ZEBRA_CREATE_DATAMATRIX( cCod, nFlags )
LOCAL hDib
FILLRECT( hDCMem, { 0, 0, nHeight, nWidth }, hBack )
HB_ZEBRA_DRAW( hZebra, { | x, y, w, h | FillRect( hDCMem, { y, x, y + h, x + w }, hBrush ) }, 0, 0, 20, 20 )
hDib = DIBFROMBITMAP( hBmp )
DIBDRAW( oPrn:hDCOut, hDib, , 500, 500 )
GLOBALFREE( hDib )
SELECTOBJECT( hDCMem, hBmpOld )
DELETEOBJECT( hBrush )
DELETEOBJECT( hBack )
HB_ZEBRA_DESTROY( hZebra )
DELETEOBJECT( hBmp )
DELETEDC( hDCMem )
RELEASEDC( GETDESKTOPWINDOW(), hDCDesk )
RETURN NIL
#include "Fivewin.ch"
#define HB_ZEBRA_FLAG_DATAMATRIX_RECTANGLE 0x0200
FUNCTION MAIN()
LOCAL oPrn
PRINT oPrn PREVIEW
PAGE
DATAMATRIX( oPrn, 500, 500, "12345678901234567890123456789012345678901234567890", 1000, 1000, HB_ZEBRA_FLAG_DATAMATRIX_RECTANGLE )
DATAMATRIX( oPrn, 1000, 500, "12345678901234567890123456789012345678901234567890", 1000, 1000, HB_ZEBRA_FLAG_DATAMATRIX_RECTANGLE )
DATAMATRIX( oPrn, 1500, 500, "18201106000006117254120000195947121000000010003896", 1000, 1000, HB_ZEBRA_FLAG_DATAMATRIX_RECTANGLE )
ENDPAGE
ENDPRINT
RETURN NIL
FUNCTION DATAMATRIX( oPrn, nRow, nCol, cCode, nWidth, nHeight, nFlags, nCodeWidth, nCodeHeight )
LOCAL hDCMem := CREATECOMPATIBLEDC( oPrn:hDC )
LOCAL hBBrush := CREATESOLIDBRUSH( CLR_BLACK )
LOCAL hWBrush := CREATESOLIDBRUSH( CLR_WHITE )
LOCAL hBmp := CREATECOMPATIBLEBITMAP( oPrn:hDC, nWidth, nHeight )
LOCAL hBmpOld := SELECTOBJECT( hDCMem, hBmp )
LOCAL hZebra := HB_ZEBRA_CREATE_DATAMATRIX( cCode, nFlags )
LOCAL hDib
DEFAULT nCodeWidth := 10
DEFAULT nCodeHeight := 10
FILLRECT( hDCMem, { 0, 0, nHeight, nWidth }, hWBrush )
HB_ZEBRA_DRAW( hZebra, { | x, y, w, h | FillRect( hDCMem, { y, x, y + h, x + w }, hBBrush ) }, 0, 0, nCodeWidth, nCodeHeight )
HB_ZEBRA_DESTROY( hZebra )
SELECTOBJECT( hDCMem, hBmpOld )
hDib = DIBFROMBITMAP( hBmp )
DIBDRAW( oPrn:hDCOut, hDib, , nRow, nCol )
GLOBALFREE( hDib )
DELETEOBJECT( hBmp )
DELETEOBJECT( hBBrush )
DELETEOBJECT( hWBrush )
DELETEDC( hDCMem )
RETURN NIL
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 42 guests