RESUELTO, mostrar un archivo JPG con IMAGE sin freeimage.dll

RESUELTO, mostrar un archivo JPG con IMAGE sin freeimage.dll

Postby albeiroval » Thu Jan 04, 2018 1:25 am

Buenas noches,

Como podria mostrar un archivo JPG con IMAGE sin tener que usar freeimage.dll, probe con XIMAGE pero
no me muestra la imagen, este es el codigo que uso :

Code: Select all  Expand view  RUN

@    1,  1 IMAGE oImage SIZE 60, 18 OF oDlg
...
@  14, 75 BTNBMP oBtn2 SIZE 70, 15 OF oDlg;
            2007;
            PROMPT "F2 = Refresca";
            LEFT;
            ACTION ( DownloadImageCaptcha(),;
                     oImage:LoadBmp( cFileCaptcha ) )

...
ACTIVATE DIALOG oDlg;
    ON INIT ( oImage:LoadBmp( cFileCaptcha ) );
    VALID lExit;
    CENTER
 
Last edited by albeiroval on Fri Jan 05, 2018 5:00 pm, edited 1 time in total.
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 378
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: mostrar un archivo JPG con IMAGE sin freeimage.dll

Postby nageswaragunupudi » Fri Jan 05, 2018 6:35 am

The main difference between IMAGE and XIMAGE is that IMAGE uses FreeImage.dll and XIMAGE does not use Freeimage.dll.
If you want to use freeimage.dll, then use IMAGE control and if not use XIMAGE control
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: mostrar un archivo JPG con IMAGE sin freeimage.dll

Postby albeiroval » Fri Jan 05, 2018 3:05 pm

Mr Rao, gracias por responder

Este es el codigo que uso :

Code: Select all  Expand view  RUN


#xtranslate  cFileCaptcha  =>  GetEnv( "USERPROFILE" ) + "\Downloads\captcha.jpg"

static Function Captcha()
  Local oDlg, oFont
  Local oImage, oSay, oGet, oBtn1, oBtn2
  Local cCode := Space(10)
  Local lExit := .F.
  Local hBmp1 := BMPYES()
  Local hBmp2 := BMPREFRESH()
   
  DownloadImageCaptcha()
 
  DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12 BOLD
   
    DEFINE DIALOG oDlg FROM 0, 0 TO 10.5, 40;
        TITLE "CAPTCHA";
        FONT oFont;
        STYLE nOr( WS_POPUP,DS_MODALFRAME,WS_CAPTION,WS_VISIBLE )

  @    1,  1 XIMAGE oImage SIZE 60, 18 OF oDlg
   
  @  2.5,  4 SAY oSay PROMPT "CODIGO :" SIZE 30, 10
   
  @  3.0,  8 GET oGet VAR cCode SIZE 60, 10
   
  @  60, 50 BTNBMP oBtn1 SIZE 70, 15 OF oDlg;
                    2007;
                    PROMPT "F3 = Acepta";
                    LEFT;
                    ACTION ( lExit := .T., oDlg:End() )
                   
  @  14, 75 BTNBMP oBtn2 SIZE 70, 15 OF oDlg;
            2007;
            PROMPT "F2 = Refresca";
            LEFT;
            ACTION ( DownloadImageCaptcha(),;
                     oImage:SetSource( cFileCaptcha ) )                  
     
  oBtn1:bPainted = {|hDC| DrawBitmap( hDC, hBmp1, 0, 0 )}  
  oBtn2:bPainted = {|hDC| DrawBitmap( hDC, hBmp2, 0, 0 )}
 
  oDlg:bKeydown  = {|nKey| KeyDownCaptcha(oBtn1, oBtn2, nKey)}
  oDlg:lhelpIcon = .F.
     
  ACTIVATE DIALOG oDlg;
    ON INIT ( oImage:SetSource( cFileCaptcha ) );
    VALID lExit;
    CENTER
       
  DeleteObject( hBmp1 ) 
  DeleteObject( hBmp2 ) 
    
Return AllTrim(cCode)

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

static Function KeyDownCaptcha( oBtn1, oBtn2, nKey )
   
    if nKey == VK_F2
       Eval(oBtn2:bAction)
    elseif nKey == VK_F3
       Eval(oBtn1:bAction)
    endif  
   
Return Nil

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

static Function DownloadImageCaptcha()
    Local cUrl  := "http://contribuyente.seniat.gob.ve/BuscaRif/Captcha.jpg"
 
  URLDOWNLOADTOFILE( 0, cUrl, cFileCaptcha )
 
Return NIL

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

DLL FUNCTION URLDOWNLOADTOFILE( pCaller AS LONG,;
                                                                cUrl AS LPSTR,;
                                                                cFileName AS LPSTR,;
                                                                nReserved AS DWORD,;
                                                                nFnCB AS LONG );
    AS LONG PASCAL;
    FROM "URLDownloadToFileA" LIB "urlmon.dll"

 


Usando XIMAGE carga la imagen con ON INIT, pero con BTNBMP oBtn2 no hace el Refresh de la imagen si necesito cambiarla.
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 378
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: mostrar un archivo JPG con IMAGE sin freeimage.dll

Postby nageswaragunupudi » Fri Jan 05, 2018 4:26 pm

Can you please change the ACTION clause of oBtn2 like this?
Code: Select all  Expand view  RUN
           ACTION ( DownloadImageCaptcha(),;
                     oImage:SetSource( "" ), ;
                     oImage:SetSource( cFileCaptcha ) )                  
 

I shall be glad if you make this modification and let me know if this is working.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: mostrar un archivo JPG con IMAGE sin freeimage.dll

Postby albeiroval » Fri Jan 05, 2018 4:56 pm

Mr Rao,

Excelente, funciona muy bien, muchas gracias.

Excellent, it works very well, thank you very much.
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 378
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela

Re: RESUELTO, mostrar un archivo JPG con IMAGE sin freeimage.dll

Postby nageswaragunupudi » Sat Jan 06, 2018 1:13 am

Thanks.

Another advice.
Instead of
Code: Select all  Expand view  RUN
 @  60, 50 BTNBMP oBtn1 SIZE 70, 15 OF oDlg;
                    2007;
                    PROMPT "F3 = Acepta";
                    LEFT;
                    ACTION ( lExit := .T., oDlg:End() )
                   
  @  14, 75 BTNBMP oBtn2 SIZE 70, 15 OF oDlg;
            2007;
            PROMPT "F2 = Refresca";
            LEFT;
            ACTION ( DownloadImageCaptcha(),;
                     oImage:SetSource( cFileCaptcha ) )                  
     
  oBtn1:bPainted = {|hDC| DrawBitmap( hDC, hBmp1, 0, 0 )}  
  oBtn2:bPainted = {|hDC| DrawBitmap( hDC, hBmp2, 0, 0 )}
 

You better write:
Code: Select all  Expand view  RUN
 @  60, 50 BTNBMP oBtn1 SIZE 70, 15 OF oDlg;
                    2007;
                    PROMPT "F3 = Acepta" RESOURCE hBmp1 ;
                    LEFT;
                    ACTION ( lExit := .T., oDlg:End() )
                   
  @  14, 75 BTNBMP oBtn2 SIZE 70, 15 OF oDlg;
            2007;
            PROMPT "F2 = Refresca" RESOURCE hBmp2 ;
            LEFT;
            ACTION ( DownloadImageCaptcha(),;
                     oImage:SetSource( cFileCaptcha ) )                  
     
  // oBtn1:bPainted = {|hDC| DrawBitmap( hDC, hBmp1, 0, 0 )}  
  // oBtn2:bPainted = {|hDC| DrawBitmap( hDC, hBmp2, 0, 0 )}
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10646
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: RESUELTO, mostrar un archivo JPG con IMAGE sin freeimage.dll

Postby albeiroval » Sat Jan 06, 2018 5:03 pm

Mr Rao, much better, thanks for the information.

Mr Rao, mucho mejor, gracias por la información.
Saludos,
Regards,

Albeiro Valencia
www.avcsistemas.com
User avatar
albeiroval
 
Posts: 378
Joined: Tue Oct 16, 2007 5:51 pm
Location: Barquisimeto - Venezuela


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 67 guests