Rectangular Data Matrix barcode

Rectangular Data Matrix barcode

Postby Enrico Maria Giordano » Thu Aug 17, 2017 3:07 pm

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
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Rectangular Data Matrix barcode

Postby Silvio.Falconi » Thu Aug 17, 2017 4:39 pm

perhaps
Image

with barlib we can make the 1D barcodes

with hzebra we can make 2D barcodes ( i think this lib also on working)

Why we cannot make a lib with all barcodes ?

for a sample I made also circular barcodes for dvd shop

I think Mastintin can help you
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: Rectangular Data Matrix barcode

Postby Massimo Linossi » Thu Aug 17, 2017 7:11 pm

Enrico, you can try this. Works perfectly.
With the standard libraries you can't make the data matrix barcode rectangular.
https://www.barcodetools.com/datamatrix/datamatrix-activex/introduction.html
User avatar
Massimo Linossi
 
Posts: 500
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Rectangular Data Matrix barcode

Postby Enrico Maria Giordano » Thu Aug 17, 2017 7:28 pm

Thank you, but I'm searching for something simpler and possibly free.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Rectangular Data Matrix barcode

Postby Enrico Maria Giordano » Fri Aug 18, 2017 1:38 pm

Found! This is a working sample:

Code: Select all  Expand view  RUN
#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


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Rectangular Data Matrix barcode

Postby karinha » Fri Aug 18, 2017 2:10 pm

Good morning Enrico.

Why does not this work?

Thank you.

Code: Select all  Expand view  RUN

#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
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7848
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Rectangular Data Matrix barcode

Postby Enrico Maria Giordano » Fri Aug 18, 2017 2:15 pm

Probably the code is too long.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Rectangular Data Matrix barcode

Postby Enrico Maria Giordano » Fri Aug 18, 2017 2:17 pm

It does work this way:

Code: Select all  Expand view  RUN
DATAMATRIX( oPrn, cText, 1000, 1000, 0 )


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Rectangular Data Matrix barcode

Postby karinha » Fri Aug 18, 2017 2:24 pm

Great Enrico. You are fantastic. Thank you very much.

Image

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7848
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Rectangular Data Matrix barcode

Postby Silvio.Falconi » Fri Aug 18, 2017 5:30 pm

why here I see it ?

Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: Rectangular Data Matrix barcode

Postby Silvio.Falconi » Fri Aug 18, 2017 5:34 pm

on ctext what we can insert ?
for a sample for a catalog product ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: Rectangular Data Matrix barcode

Postby Enrico Maria Giordano » Sat Aug 19, 2017 9:54 am

Simplified and added more parameters:

Code: Select all  Expand view  RUN
#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


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 39 guests