FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour usando servicios Generador de codigo QR
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: usando servicios Generador de codigo QR
Posted: Wed Aug 19, 2015 12:54 PM

Bu茅n dia. porfa como hago para generar en uno de estes formatos: JPG, 贸 BMP, 贸 GIF, 贸 WMF, 贸 EMF ??

Gracias, saludos.

Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: usando servicios Generador de codigo QR
Posted: Thu Aug 20, 2015 01:00 PM

Up

Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: usando servicios Generador de codigo QR
Posted: Thu Aug 20, 2015 05:14 PM

Karinha . La consulta es sobre el sistema de Daniel o sobre mi c贸digo ?
Mi c贸digo usa gdiplus ,por lo que con muy pocos cambios se podr铆a grabar en cualquiera de los formatos que propones . El sistema que propone Daniel por lo que veo usa un bitmap , lo que supone que tambi茅n se podr铆an grabar en los otros formatos . Todo depende al final de la version fwh que poseas y si esta ya tiene incluido el c贸digo gdiplus que necesitas .

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: usando servicios Generador de codigo QR
Posted: Thu Aug 20, 2015 05:21 PM

Hola, estoy probando ellos. 驴c贸mo puedo en su ejemplo? Gracias, saludos.

fwh1505

Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: usando servicios Generador de codigo QR
Posted: Thu Aug 20, 2015 08:27 PM
en esta parte del codigo ...
Code (fw): Select all Collapse
  if msgYesNo( " 篓 quiere grabar el codigo QR a Disco ?")
       oGBmp:save(".\qrcode.png" )
    endif


Solo cambia por el formato que quieras grabar ....

Code (fw): Select all Collapse
  oGBmp:save(".\qrcode.bmp" )
 oGBmp:save(".\qrcode.gif" )
 oGBmp:save(".\qrcode.jpg" )
 oGBmp:save(".\qrcode.EMF" )
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: usando servicios Generador de codigo QR
Posted: Fri Aug 21, 2015 12:25 PM

Gracias, mas el lector de QRCODE, cuando 茅s PNG pasa, mas cuando 茅s .JPG por ejemplo, dice que el formato 茅s inv谩lido. ??

Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: usando servicios Generador de codigo QR
Posted: Fri Aug 21, 2015 01:15 PM
Mister Mastintin,

Code (fw): Select all Collapse
   Formatos soportados...
   21/08/2015  10:07             7.998 qrcode.bmp
   21/08/2015  10:07             3.565 qrcode.gif
   21/08/2015  10:07            13.707 qrcode.jpg
   21/08/2015  10:07               389 qrcode.png

   // FORMATO NO SOPORTADO
   oGBmp:save(".\qrcode.emf" )

   // FORMATO NO SOPORTADO
   oGBmp:save(".\qrcode.wmf" )

   // FORMATO NO SOPORTADO
   oGBmp:save(".\qrcode.ico" )


Gracias, saludos.

Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: usando servicios Generador de codigo QR
Posted: Sat Aug 22, 2015 06:44 PM
karinha wrote:Mister Mastintin,

Code (fw): Select all Collapse
聽 聽Formatos soportados...
聽 聽21/08/2015 聽10:07 聽 聽 聽 聽 聽 聽 7.998 qrcode.bmp
聽 聽21/08/2015 聽10:07 聽 聽 聽 聽 聽 聽 3.565 qrcode.gif
聽 聽21/08/2015 聽10:07 聽 聽 聽 聽 聽 聽13.707 qrcode.jpg
聽 聽21/08/2015 聽10:07 聽 聽 聽 聽 聽 聽 聽 389 qrcode.png

聽 聽// FORMATO NO SOPORTADO
聽 聽oGBmp:save(".\qrcode.emf" )

聽 聽// FORMATO NO SOPORTADO
聽 聽oGBmp:save(".\qrcode.wmf" )

聽 聽// FORMATO NO SOPORTADO
聽 聽oGBmp:save(".\qrcode.ico" )


Gracias, saludos.



el formato Tif tambi茅n es posible :-)

Karinha . Es correcto , los formatos emf,wmf,e ico son soportados como formatos de entrada , pero no como formatos de salida .
Seguro que se puede crear alguna funci贸n que grabe en esos formatos desde un bitmap , incluso podemos sacar el hicon de un bitmap gdi+ , pero de momento no est谩 realizado ( que yo sepa ) .
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: usando servicios Generador de codigo QR
Posted: Mon Aug 24, 2015 01:04 PM


Code (fw): Select all Collapse
// Our first DialogBox sample

#include "FiveWin.ch"
#include "ttitle.ch"

# define HTTPREQUEST_PROXYSETTING_PROXY  2

// Para xHarbour

#IFDEF __XHARBOUR__
  #xtranslate hb_DateTime([<x,...>])          => DateTime(<x>)
  #xtranslate hb_tstostr([<x>])               => TToS(<x>)
  #xtranslate hb_stot([<x>])                  => SToT(<x>)
  #xtranslate hb_ttod([<x>])                  => TToD(<x>)
  #xtranslate hb_hour([<x>])                  => Hour(<x>)
  #xtranslate hb_minute([<x>])                => Minute(<x>)
  #xtranslate hb_sec([<x>])                   => Secs(<x>)
  #xtranslate hb_NumToHex([<x>])              => NumToHex(<x>)
  #xtranslate hb_StrFormat([<x,...>])         => StrFormat(<x>)
  #xtranslate <x>:__EnumIndex                 => hb_EnumIndex
#ENDIF

MEMVAR SEQUENC

function Main()

   local obmp ,cBmp
   local oDlg, oIco
   local ofont
   local cCode:= space(440)  // maximo de 440 caracteres por qrcode.

   // Master Mastintin: con 431 caracteres el formato es invalido, porque?
   // Que me falta?  Prueba porfa
   SEQUENC := "35141146377222003730599000004630001158179941|20141105134922|10.00|61694805808|m+4o8FY1lig1zcy6VU3t7INVwE6kiA/ykLXKDFZfb9gu0g4wl3Fk2HYaRhSt8G+yk9mP/R65m3R7V2IO8CxnmO1oVtlamB6UKA+UZZqDNEqtYlhQzLySNzMG0thaNMZsq5RxmQ3eQLPw8LLez3MqWvUveFXNSSq6AGEX2+KOdavteo3K2L06SQoVIjwkmcgRzqhfHP3y8t2wfr1nw/WAnaCF9ZY/K4dTykk3hsXcan/MKCTBlcSOhNgSh3sdsQHpl2w2tmbLBsYBLFkuvKlwzHarNJQ1RfRznGdojHglQH1KVtbAUXKke54pdRt3JL7nJlR+Lbmtd2tjcT2vRyTepw=="

   cCode := ALLTRIM( SEQUENC )

   DEFINE Font ofont NAME "Verdana" SIZE 0,14 
    
   DEFINE ICON oIco FILE "..\icons\fivewin.ico"

   DEFINE DIALOG oDlg TITLE "Qrcode Generator" ;
      ICON oIco SIZE 350, 440

   @ 30,24  IMAGE oBmp FILE cBmp OF oDlg size 128,128 pixel NOBORDER 
     
     oBmp:lTransparent := .t.
     
   //  cargaBmp( "hola",oBmp )
       
 
     @ 160, 10 SAY "Introduce el codigo a generar :" size 100, 12 ;
                        FONT oFont pixel OF oDlg
     
     @ 170, 10 GET cCode size 120, 12 FONT oFont pixel OF oDlg MEMO

     @ 205, 85 BUTTON "&Buscar" SIZE 40, 12 OF oDlg pixel ;
              FONT oFont ; 
              ACTION cargaBmp( alltrim( cCode) ,oBmp )

     @ 205,130 BUTTON "&Salir" SIZE 40, 12 pixel OF oDlg;
               FONT oFont ; 
               ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED ;
    ON INIT  DlgBarTitle( oDlg, "  Generador de Qrcode","" ,44 )  ;
    ON PAINT DlgStatusBar(oDlg, 68,, .t. ) 
   
return nil

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

Function cargaBmp( cCode, oImage )
 local cResp
 local nZeroZeroClr
 local ogbmp := GdiBmp():new()
 local nHeight := 248
 local nWidth  := 248
 local cUrl  := "http://api.qrserver.com/v1/create-qr-code/?data="
 
  cUrl += GetSafeURL(hb_strtoutf8( cCode ) )
  cUrl += "&size=" + alltrim( str( nWidth ) )  + "x" + alltrim( str( nHeight ) )
   
 cResp := loadBmp(cUrl)

 if !Empty( cResp ) 
 
    oGbmp:hbmp := GDIPLUSIMAGELOADPNGFROMSTR( cResp,len(cResp) ) 
   
    oImage:hBitmap := oGBmp:GetGDIHbitmap()
    oImage:HasAlpha()
    oImage:Refresh()
    if msgYesNo( " 篓 quiere grabar el codigo QR a Disco ?")


       oGBmp:save(".\qrcode.png" )  // FORMATO INVALIDO ?


    endif  
    oGbmp:End()
 endif
 
Return nil

Static Function GetSafeURL(  cUrl ) 
   local cAsc
   local nChr
   local sHex
   local i
   local cGetSafeURL := ""
       
    For i = 1 To Len( cUrl )
        cASC := substr( cUrl, i, 1)
        nChr := Asc( cASC )
        
        If ( nChr > 47 .and. nChr < 58 ) .Or. ( nChr > 64 .And. nChr < 91 ) .Or. ( nChr > 96 .And. nChr < 123 ) 
            cGetSafeURL += cASC
        Else
            sHex :=  hb_NumtoHex( nChr )
            If Len( sHex ) = 1 
                cGetSafeURL += "%0" + sHex
            Else
                cGetSafeURL += "%"  + sHex
            End If
        End If
    Next

Return cGetSafeURL 

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

Function loadBmp(cUrl)
local oHttp
local cResp := nil

   Try
      oHttp := CreateObject( "winhttp.winhttprequest.5.1" )
         
      oHttp:Open("GET", cUrl, .f. )
      oHttp:Send()
      cResp := oHttp:ResponseBody()
          
   Catch
      MsgStop( "Error" )
      Return cResp
   End Try
  
Return cResp

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

Function DlgStatusBar(oDlg, nHeight, nCorrec , lColor )
Local nDlgHeight := oDlg:nHeight
Local aColor     := { { 0.40, nRGB( 200, 200, 200 ), nRGB( 184, 184, 184 ) },;
                    { 0.60, nRGB( 184, 184, 184 ), nRGB( 150, 150, 150 ) } }

DEFAULT nHeight  := 72
DEFAULT nCorrec  := 0
DEFAULT lColor   := .F.

nDlgHeight:= nDlgHeight+ncorrec
IF lColor
   GradienTfill(oDlg:hDC,nDlgHeight-( nHeight-2 ),0,nDlgHeight-20,oDlg:nWidth, aColor ,.t.)
   WndBoxIn( oDlg:hDc,nDlgHeight-( nHeight-1 ),0,nDlgHeight-( nHeight ),oDlg:nWidth )
ELSE
   WndBoxIn( oDlg:hDc,nDlgHeight -( nHeight-1 ),4,nDlgHeight-( nHeight ),oDlg:nWidth - 10 )
endif

Return Nil

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

FUNCTION DlgBarTitle( oWnd, cTitle, cBmp ,nHeight )
   LOCAL oFont
   LOCAL oTitle
   LOCAL nColText := 180
   LOCAL nRowImg  := 0
   

   DEFAULT cTitle  := ""
   DEFAULT nHeight := 48

   IF nHeight < 48
      nColText := 60
      nRowImg  := 12
      DEFINE FONT oFont NAME "Arial" size 10, 30
   ELSE
      DEFINE FONT oFont NAME "Arial" size 12, 30
   endif

    @ -1, -1  TITLE oTitle size oWnd:nWidth+1, nHeight+1 of oWnd SHADOWSIZE 0
   
   @  nRowImg,  10  TITLEIMG  OF oTitle BITMAP cBmp  SIZE 48, 48 REFLEX ;
          TRANSPARENT
   
    @  nRowImg-2 ,  nColText TITLETEXT OF oTitle TEXT cTitle COLOR CLR_BLACK FONT oFont

    oTitle:aGrdBack := { { 1, RGB( 255, 255, 255 ), RGB( 229, 233, 238 )  } }
    oTitle:nShadowIntensity = 0
    oTitle:nShadow = 0
    oTitle:nClrLine1 := nrgb(0,0,0)
    oTitle:nClrLine2 := RGB( 229, 233, 238 )
    oWnd:oTop:= oTitle
    
      

RETURN oTitle


Jo茫o Santos - S茫o Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: usando servicios Generador de codigo QR
Posted: Tue Aug 25, 2015 07:35 AM

Karinha , aqu铆 el c贸digo parece ir bien con cadenas de hasta 440 caracteres .
驴 Podr谩 ser problema de velocidad de internet ? . yo tengo una conexi贸n muy buena por lo que el retorno es instant谩neo . Puede pasar que cuando el programa llega al c贸digo que genere la imagen del Qrcode , el stream desde donde se genera a煤n no se recibi贸 completamente y por eso falle , pero eso es una suposici贸n.

Continue the discussion