FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Como grabar un codiigo en qr a un Archivo BMP
Posts: 37
Joined: Tue May 12, 2009 08:45 PM
Como grabar un codiigo en qr a un Archivo BMP
Posted: Fri Jan 26, 2018 12:06 AM

Ayudaaaa.

Me muestra en Pantalla pero no se como grabar a un bmp o jpg

include "fivewin.ch"

function main()
local oWnd
define window oWnd
activate window oWnd on paint( BarCode( hDC ) )
return nil

function BarCode( hDC )
local hZebra
local cCode := "20219719443 | 01 | F001 | 00045256 | 25/01/2018 | 18.00 | 118.00 | 6 | 10087302682 |"
local hBrush := CreateSolidBrush( 0 )
hZebra := hb_zebra_create_qrcode( cCode, NIL )
hb_zebra_draw( hZebra, {| x, y, w, h | FillRect( hDC, { y, x, y + h, x + w }, hBrush ) }, 5, 5, 4, 4 )
deleteobject( hBrush )
hb_zebra_destroy( hZebra )
return nil

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Como grabar un codiigo en qr a un Archivo BMP
Posted: Fri Jan 26, 2018 09:25 AM

oWnd:SaveToBmp( "mycode.bmp" )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 37
Joined: Tue May 12, 2009 08:45 PM
Re: Como grabar un codiigo en qr a un Archivo BMP
Posted: Fri Jan 26, 2018 01:30 PM

Hola Antonio Gracias x responder..

Me graba la pantalla.

Lo que quiero saber es como grabar solo el codigo de QR que se crea.
para utilizar en mi facturacion electronica.

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Como grabar un codiigo en qr a un Archivo BMP
Posted: Fri Jan 26, 2018 01:47 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 37
Joined: Tue May 12, 2009 08:45 PM
Re: Como grabar un codiigo en qr a un Archivo BMP
Posted: Fri Jan 26, 2018 05:34 PM

Hola Karina excelente tu aporte.

Sabes ise la prueba y va muy bien pero funciona solo con internet.

En el ejemplo que dejo utilizo la liberia hbzebra de harbour, lo cual me permite crear codigo ilimitados de qr pdf437 etc.
El problema es si ya esta creado el brush como convertirlo en archivo bmp y luego grabarlo.

de antemano muy agradecido...

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Como grabar un codiigo en qr a un Archivo BMP
Posted: Fri Jan 26, 2018 06:53 PM

Dioni,

Cambia el tamaño de la ventana con:

oWnd:SetSize( 164, 185 )

antes de llamar a:

oWnd:SaveToBmp( "mycode.bmp" )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Como grabar un codiigo en qr a un Archivo BMP
Posted: Fri Jan 26, 2018 07:06 PM
Dioni, además de probar lo que te dice Antonio, que es simple y sencillo, puedes probar esto

Code (fw): Select all Collapse
#include "fivewin.ch"

Static oFontText
Static oWnd
Static lPaint    := .T.
Static hZebra
Static hBrush
Static nWidth   := 0
Static nHeight  := 0

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

Function Main()

   DEFINE FONT oFontText NAME "Calibri" SIZE 0, -11

   DEFINE WINDOW oWnd FROM 10, 10 TO 700, 700 PIXEL MENU MyMenu()
   
   ACTIVATE WINDOW oWnd ON PAINT BarCode()
   
   RELEASE FONT oFontText
   DeleteObject( hBrush )
   hb_Zebra_Destroy( hZebra )

return nil

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

Function MyMenu()

   local oMenu
   MENU oMenu
      MENUITEM "Actions"
      MENU
         MENUITEM "Save" ACTION SaveCode()
         SEPARATOR
         MENUITEM "Exit" ACTION oWnd:End()
      ENDMENU
   ENDMENU

Return oMenu

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

function BarCode()

   local nX       := 18
   local nY       := 18
   local hFont
   local cCode    := "20219719443 | 01 | F001 | 00045256 | 25/01/2018 | 18.00 | 118.00 | 6 | 10087302682 |"
   
   if Empty( hBrush )
      hBrush         := CreateSolidBrush( 0 )
      hZebra         := hb_Zebra_Create_Qrcode( cCode, NIL )
      hb_zebra_draw( hZebra, { | x, y, w, h | nWidth :=  x + w, nHeight := y + h, ;
                               FillRect( oWnd:hDC, { y, x, y + h, x + w }, hBrush ) }, nX, nY, 11, 11 )
      oFontText:Activate( oWnd:hDC )
      DrawText( oWnd:hDC, cCode, { nHeight + 10 , nX - 4, nHeight + 24, nWidth + 4 }, 0 ) 
      oFontText:DeActivate( oWnd:hDC )
   endif

return nil

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

Function SaveCode()

   local oBmp
   local hGraf
   local hBmp
   local hBrush1  := GdiPlusNewSolidBrush( 255, 255, 255, 255 )
   local hBrush2  := GdiPlusNewSolidBrush( 255, 0, 0, 0 )
   oBmp           := GdiBmp():New()
   hBmp           := GdiPlusBmpFromBrush( nWidth + 18, nHeight + 18, hBrush1 )
   hGraf          := GdiPlusHGraFFromHBmp( hBmp )
   hb_zebra_draw( hZebra, { | x, y, w, h | GdiPlusDrawRect( hGraf, , hBrush2, x, y, w, h ) }, 18, 18, 11, 11 )
   oBmp:hBmp      := hBmp
   GdiPlusDeleteGraphics( hGraf )
   GdiPlusDeleteBrush( hBrush2 )
   GdiPlusDeleteBrush( hBrush1 )
   oBmp:Save( "Code1.png" )
   oBmp:End()

Return nil

//----------------------------------------------------------------------------//
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
Posts: 37
Joined: Tue May 12, 2009 08:45 PM
Re: Como grabar un codiigo en qr a un Archivo BMP (Listo)
Posted: Sat Jan 27, 2018 05:21 AM

Gracias MAESTRO CNAVARRO con tu aporte, pude concluir mi factura.

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Como grabar un codiigo en qr a un Archivo BMP
Posted: Sat Jan 27, 2018 03:20 PM

No olvidar a nuestro querido compañero Manuel ( mastintin ) que nos ha abierto este fascinante mundillo del GDIPLUS

viewtopic.php?f=6t=34558p=205381hilit=Zebra#p205397

&&&

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

Continue the discussion