Ayuda cpm hbzebra.lib

Ayuda cpm hbzebra.lib

Postby Willi Quintana » Wed Sep 06, 2017 6:11 am

Hola amigos:
Tengo este código, que pinta una imagen en la pantalla. lo que no puedo es cargar la imagen a una variable para poder grabarla como archivo bmp
Gracias mil
Code: Select all  Expand view

function main()
local oWnd

define window oWnd
activate window oWnd on paint( BarCode( hDC ) )

return nil

function BarCode( hDC )

   local hZebra
   local cCode := "testing from fivewin"
   local hBrush := CreateSolidBrush( 0 )

   hZebra := hb_zebra_create_pdf417( cCode, NIL )
   hb_zebra_draw( hZebra, {| x, y, w, h | FillRect( hDC, { y, x, y +  h, x + w }, hBrush ) }, 5, 5, 1, 4 )

   hb_zebra_destroy( hZebra )

   deleteobject( hBrush )

return(nil)

 
User avatar
Willi Quintana
 
Posts: 1001
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú

Re: Ayuda cpm hbzebra.lib

Postby Busmatic_wpb » Thu Sep 07, 2017 1:16 am

Mira yo lo hago asi

#include "fivewin.ch"
#include "codebar.ch"

static oCode, oWndP

function Main()

local oMenu

oCode := TCodeBars():New()

oMenu = BuildMenu()
**

BuildCode( CODEBAR_DATAMATRIX, "DataMatrix :)")

* define window oWndP menu oMenu
* activate window oWndP &&ON INIT (BuildCode( CODEBAR_DATAMATRIX, "DataMatrix :)", oWndP:end() ))

return nil

function BuildMenu()

local oMenu

menu oMenu
menuitem "CodeBar"
menu
menuitem "EAN13" action( BuildCode( CODEBAR_EAN13, "477012345678" ) )
menuitem "EAN8" action( BuildCode( CODEBAR_EAN8, "1234567" ) )
menuitem "UPCA" action( BuildCode( CODEBAR_UPCA, "01234567891" ) )
menuitem "UPCE" action( BuildCode( CODEBAR_UPCE, "123456" ) )
menuitem "CODE39" action( BuildCode( CODEBAR_CODE39, "ABC123" ) )
menuitem "ITF" action( BuildCode( CODEBAR_ITF, "1234", HB_ZEBRA_FLAG_WIDE3 ) )
menuitem "MSI" action( BuildCode( CODEBAR_MSI, "1234567", HB_ZEBRA_FLAG_CHECKSUM ) )
menuitem "CODABAR" action( BuildCode( CODEBAR_CODABAR, "40156", HB_ZEBRA_FLAG_WIDE3 ) )
menuitem "CODE93" action( BuildCode( CODEBAR_CODE93, "ABC-123" ) )
menuitem "CODE11" action( BuildCode( CODEBAR_CODE11, "12", HB_ZEBRA_FLAG_WIDE3 ) )
menuitem "CODE128" action( BuildCode( CODEBAR_CODE128, "Code 128") )
menuitem "PDF417" action( BuildCode( CODEBAR_PDF417, "PDF17" ) )
menuitem "DATAMATRIX" action( BuildCode( CODEBAR_DATAMATRIX, "DataMatrix :)") )
endmenu
endmenu

return oMenu

function BuildCode( nCode, cCode, nFlags )

* local hDC := oWndP:GetDC()

default nFlags := 0


oCode:Reset()
if nCode < CODEBAR_PDF417
oCode:nHeightCode = oCode:nHeight - 50
oCode:nWidthCode = 1.5
else
oCode:nHeightCode = 3
oCode:nWidthCode = 1
endif
oCode:SetType( nCode )
oCode:SetCode( cCode )
oCode:SetFlags( nFlags )
oCode:Build()

* DrawBitmap( hDC, oCode:hCodeBar, 0, 0 ) && aqui lo pinta en la pantalla

DrawBitmap( oCode:hCodeBar,10, 10 ) && aqui lo mando a un archivo file.bmp de 10x10 tam
hDib := DibFromBitmap(oCode:hCodeBar )
DibWrite( "file.bmp" , hDib )

* oWndP:ReleaseDC()
* oWndP:END()

return nil
Regards.
S.I.T.U.
Sistemas Inteligentes de transporte urbano
http://www.situcr.com
oscarchacon@Situcr.com
Desarrollos BA4/B4j androide
User avatar
Busmatic_wpb
 
Posts: 162
Joined: Wed Feb 22, 2017 2:19 am

Re: Ayuda cpm hbzebra.lib

Postby Willi Quintana » Thu Sep 07, 2017 4:55 am

Gracias mi amigo, eso funciona perfectamente con la librería externa de zebra y con XHarbour
estoy migrando Harbour 3.2.0, que tiene la librería hbzebra y el ejemplo es el que puse arriba,, y no veo la manera de pasarlo a un file..

Un abrazo..
User avatar
Willi Quintana
 
Posts: 1001
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú

Re: Ayuda cpm hbzebra.lib

Postby mastintin » Thu Sep 07, 2017 8:59 am

Yo tengo una función que te puede ser util....
Usa gdiplus y no se si te faltará alguna funcion gdiplus ( en caso de faltar pidela )
El codigo que te pongo es para qrcode pero lo he comentado y te lo he puesto para pdf417. No lo he probado con pdf417 .

Code: Select all  Expand view


Function DrawgdiBarcodeBMP( nLineWidth, nLineHeight, cVar, cfileName )  
   local oBmp := GDIBmp():new()

   //local hZebra := hb_zebra_create_ean13( "477012345678" )
   //LOCAL hZebra := hb_zebra_create_qrcode( cVar )
   local hZebra := hb_zebra_create_pdf417( cVar, NIL )
   LOCAL nFlags
   local nWidth, nHeight
   local hBmp, hGraf
   local hBrush  := GdiPlusNewSolidBrush( 255, 255, 255, 255 )
   local hBrush2 := GdiPlusNewSolidBrush( 255, 0, 0, 255 )

   // nLineHeight := nLineWidth

   nWidht  := hb_Zebra_GetWidth ( hZebra, nLineWidth, nLineHeight, nFlags )
   nHeight := hb_Zebra_GetHeight( hZebra, nLineWidth, nLineHeight, nFlags )


   hBmp  := GDIPLUSBMPFROMBRUSH( nWidht + 2, nHeight+2, hBrush )
   hGraf := GDIPLUSHGRAFFROMHBMP( hBmp )

   hb_zebra_draw_gdip( hZebra, hGraf, hBrush2, 1, 1, nLineWidth, nLineHeight )

   oBmp:hBmp := hBmp

   GdiPlusDeleteGraphics( hGraf )
   GdiPlusDeleteBrush( hBrush )
   GdiPlusDeleteBrush( hBrush2 )

   HB_ZEBRA_DESTROY( hZebra )

   oBmp:Save( cFileName )
   oBmp:END()


Return nil


STATIC FUNCTION hb_zebra_draw_gdip( hZebra, hGraf, hBrush, ... )

   hb_zebra_draw( hZebra, {| x, y, w, h |  GDIPLUSDRAWRECT( hGraf,,hbrush,x, y, w, h ) }, ... )

RETURN 0



 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Ayuda cpm hbzebra.lib

Postby Willi Quintana » Sat Sep 09, 2017 1:40 pm

Gracias,,,, funciona ok,,,, y como cambio el color en gdi???
Salu2
User avatar
Willi Quintana
 
Posts: 1001
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú

Re: Ayuda cpm hbzebra.lib

Postby mastintin » Sat Sep 09, 2017 9:39 pm

Willi Quintana wrote:Gracias,,,, funciona ok,,,, y como cambio el color en gdi???
Salu2

Puedes utilizar los colores que necesites solo cambiandolo aqui ...
hBrush2 es el color del codebar
hbrush el color del fondo
Code: Select all  Expand view


local hBrush  := GdiPlusNewSolidBrush( 255, 255, 255, 255 )
local hBrush2 := GdiPlusNewSolidBrush( 255, 0, 0, 255 )

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Ayuda cpm hbzebra.lib

Postby byte-one » Sun Mar 04, 2018 3:42 pm

Mr. Mastintin, where are this functions?
Code: Select all  Expand view
nWidht  := hb_Zebra_GetWidth ( hZebra, nLineWidth, nLineHeight, nFlags )
   nHeight := hb_Zebra_GetHeight( hZebra, nLineWidth, nLineHeight, nFlags )
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Ayuda cpm hbzebra.lib

Postby cnavarro » Sun Mar 04, 2018 6:07 pm

Gunther

Code: Select all  Expand view

//------------------------------------------------------------------------------

FUNCTION hb_Zebra_GetWidth ( hZebra, nLineWidth, nLineHeight, nFlags )

LOCAL x1:= 0, y1 := 0, nBarWidth := 0, nBarHeight := 0

   IF hb_zebra_GetError( hZebra ) != 0
      RETURN HB_ZEBRA_ERROR_INVALIDZEBRA
   ENDIF
   hb_zebra_draw ( hZebra, {| x, y, w, h | nBarWidth:=x+w-x1, nBarHeight:=y+h-y1 }, x1, y1, nLineWidth, nLineHeight, nFlags )
RETURN nBarWidth

//------------------------------------------------------------------------------

FUNCTION hb_Zebra_GetHeight (hZebra, nLineWidth, nLineHeight, nFlags )

LOCAL x1:= 0, y1 := 0, nBarWidth := 0, nBarHeight := 0

   IF hb_zebra_GetError( hZebra ) != 0
      RETURN HB_ZEBRA_ERROR_INVALIDZEBRA
   ENDIF
   hb_zebra_draw ( hZebra, {| x, y, w, h | nBarWidth:=x+w-x1, nBarHeight:=y+h-y1 }, x1, y1, nLineWidth, nLineHeight, nFlags )
RETURN nBarHeight

//------------------------------------------------------------------------------

 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Ayuda cpm hbzebra.lib

Postby byte-one » Mon Mar 05, 2018 8:40 am

THANKS!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Ayuda cpm hbzebra.lib

Postby byte-one » Mon Mar 05, 2018 1:17 pm

Christobal, please try QR-Code with data "aa1"! You can see, that the last block is not to see! It seems as a bug in zebra. DATAMATRIX is ok.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Ayuda cpm hbzebra.lib

Postby cnavarro » Mon Mar 05, 2018 2:42 pm

Sorry, I do not understand well

Image
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Ayuda cpm hbzebra.lib

Postby byte-one » Mon Mar 05, 2018 3:09 pm

Cristobal, please try with this code! The code are made ok, but the function hb_zebra_Getwidth(...) returns wrong width-result. I found, that this behavoir is on mode "alphanumeric" in the QR-sourcecode but not in all cases.

Code: Select all  Expand view
Function DrawgdiBarcodeBMP( cVar, cBmp, nWidth )
   local oBmp , hZebra
   LOCAL nFlags
   local nLineWidth := 10
   local nWidth_temp //:= 177*nLineWidth
   local hBmp, hGraf
   local hBrush  := GdiPlusNewSolidBrush( 255, 255, 255, 255 )
   local hBrush2 := GdiPlusNewSolidBrush( 255, 0, 0, 0 )

   DEFAULT cBmp := ".\QR.bmp" , nWidth := 200
  hZebra := hb_zebra_create_qrcode( cVar , nFlags)
   nWidth_temp := hb_Zebra_GetWidth ( hZebra, nLineWidth, nLineWidth, nFlags )
    oBmp := GDIBmp():new()
    hBmp  := GDIPLUSBMPFROMBRUSH( nWidth_temp, nWidth_temp, hBrush )
    hGraf := GDIPLUSHGRAFFROMHBMP( hBmp )
    hb_zebra_draw( hZebra, {| x, y, w, h |  GDIPLUSDRAWRECT( hGraf,,hbrush2,x, y, w, h ) },0,0,nLineWidth, nLineWidth, nFlags )
    GdiPlusDeleteGraphics( hGraf )
HB_ZEBRA_DESTROY( hZebra )
GdiPlusDeleteBrush( hBrush )
GdiPlusDeleteBrush( hBrush2 )
oBmp:hBmp := hBmp
oBmp:Save( cBmp )
oBmp:END()

return if(file(cBmp),cBmp,"")
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Ayuda cpm hbzebra.lib

Postby cnavarro » Mon Mar 05, 2018 4:20 pm

Look your mail
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 14 guests