A solution for BTNBMP using animated GIF's

A solution for BTNBMP using animated GIF's

Postby ukoenig » Mon Jun 20, 2016 10:25 am

Hello,

is it possible to display a animated GIF inside BTNBMP ?

I can use a TRANSPARENT button and split the animated GIF to it single images
Next using oBtn:SetFile(Frame&No.gif ) inside a loop on buttonclick
but I need up to 20 single images.
Next to perform the ACTION during the GIF is running.
Maybe possible ?

It would be a nice extension of BTNBMP.
For the moment only the 1. image is displayed.

Image

regards
Uwe :?:
Last edited by ukoenig on Tue Jul 05, 2016 5:56 pm, edited 6 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: BTNBMP with animated GIF ?

Postby cnavarro » Mon Jun 20, 2016 2:04 pm

I do not understand your needs
But this works for me

Code: Select all  Expand view

#include "FiveWin.ch"
#include "gif.ch"

function Main()

   local oDlg, oBtn

   DEFINE DIALOG oDlg TITLE "Attention" SIZE 400, 600

   @ 2, 11 BUTTONBMP oBtn PROMPT "Waiting to use the calculator" SIZE 120, 200 PIXEL ACTION MsgInfo( "Hello" )

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT PlaceGif( oBtn )

return nil

function PlaceGif( oDlg )

   local oGif

   @ 19, 10 GIF oGif FILENAME "..\gifs\gif05.gif" OF oDlg

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
User avatar
cnavarro
 
Posts: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: BTNBMP with animated GIF ?

Postby ukoenig » Mon Jun 20, 2016 2:24 pm

Cristobal,

that is NOT the result, I'm looking for
the problem : the animated GIF is NOT shown transparent and the button-action is disabled
as well NO tooltip and NO prompt is visible !!!

You can download my complete sample, to see what I mean :
( as well You can enable Your solution < PLACEGIF > for a test )

http://www.pflegeplus.com/DOWNLOADS/Anigif2.zip

the RESULT using function < PLACEGIF >

Image

my solution :
replacing the button-image calling a gif-paint-function

@ 30, 85 BTNBMP oBtn[7] SIZE 90, 90 OF oDlg 2007 ;
FILENAME c_path1 + "Animat_1.gif" ; // the 1. image of a set. Using a animated gif, only the 1. image is visible
CENTER ROUND ;
PROMPT "&Run .." ;
FONT oTextFont ;
ACTION ( RUN_ACTION(oBtn), lRun := .T., GIF_RUN(oBtn) )
// calling the single images of a defined set. The animated GIF is splitted to the single-images
oBtn[7]:lTransparent := .T.
oBtn[7]:SetColor( 128 )
oBtn[7]:cTooltip := { "RUN" + CRLF + ;
"animated GIF","RUN", 1, CLR_BLACK, 14089979 }

regards
Uwe :roll:
Last edited by ukoenig on Wed Jun 22, 2016 11:01 am, edited 2 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: BTNBMP using animated GIF's ?

Postby cnavarro » Mon Jun 20, 2016 6:57 pm

Uwe, your sample run OK, for me

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: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: BTNBMP using animated GIF's ?

Postby cnavarro » Mon Jun 20, 2016 7:28 pm

Uwe, sorry,
Now I understand your problem
I'll investigate
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: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: BTNBMP using animated GIF's ?

Postby ukoenig » Mon Jun 20, 2016 7:59 pm

Cristobal,

I added another set in blue using bmp-format NO alpha < 1.bmp - 18.bmp >
( works as well and can be created as resource )
added a different start and endimage

The solution could be used like in windows shutdown or start ( with button-style NOBORDER )

http://www.pflegeplus.com/DOWNLOADS/Anigif2.zip

regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: BTNBMP using animated GIF's ?

Postby mastintin » Mon Jun 20, 2016 10:09 pm

Cristobal . Si interesa tengo algo con gdiplus que funciona con un código muy similar pero sin crear los frames externos ...
el código seria similar a esto . ( faltaría liberar hbitmaps )
el exe funcionando https://www.dropbox.com/s/srnfuaa84h9rn ... n.exe?dl=0
Code: Select all  Expand view


FUNCTION GIF_RUN(oBtn)
local hbitmap
local hbmpFrame
local hbmp
LOCAL I := 1
local nLen

hbmp:= GDIPLUSIMAGEFFILE( c_path1 + "animat" + ".gif" )
if  GDIPLUSISANIMATEDGIF( hbmp )
    nLen:= GDIPLUSIMGGETFRAMECOUNT(hbmp)
    DO WHILE lRun = .T.
    FOR I := 1 TO nLen
        IF lRun = .F.
            EXIT
        ENDIF
               hbmpFrame := GDIPLUSIMGGETFRAME(hbmp, i)
               hBitmap:= GdiPlusCreateHBitmapImage( hbmpFrame )
               oBtn[7]:LoadBitmaps(  bitmap )
               oBtn[7]:Refresh()
        SYSWAIT(0.1)
    NEXT
   ENDDO
endif
oBtn[7]:Refresh()

RETURN NIL

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

Re: BTNBMP using animated GIF's ?

Postby cnavarro » Mon Jun 20, 2016 10:20 pm

Manuel, si, eso ya lo había visto, muchas gracias
El problema es que cuando se muestra un GIF ( no las imágenes sucesivamente como ahora ), el GIF no se muestra transparente

Saludos

Manuel, yes, that I had already seen, thank you very much
The problem is that when shown a GIF (not images successively as now), the GIF is not displayed transparent

Regards
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: 6548
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: BTNBMP using animated GIF's ?

Postby mastintin » Tue Jun 21, 2016 8:52 am

cnavarro wrote:Manuel, si, eso ya lo había visto, muchas gracias
El problema es que cuando se muestra un GIF ( no las imágenes sucesivamente como ahora ), el GIF no se muestra transparente

Saludos

Manuel, yes, that I had already seen, thank you very much
The problem is that when shown a GIF (not images successively as now), the GIF is not displayed transparent

Regards


Cristobal en mis pruebas aqui ....

si uso como imagen

@ 30, 85 BTNBMP oBtn[7] SIZE 90, 90 OF oDlg 2007 ;
FILENAME c_path1 + "Animat_1" + ".gif" ;

la imagen me sale con fondo negro


@ 30, 85 BTNBMP oBtn[7] SIZE 90, 90 OF oDlg 2007 ;
FILENAME c_path1 + "Animat" + ".gif" ;

la imagen sale trasparente .

Si miras la diferencia entre ellas es que ésta ultima su tipo es RGB 8 bits mientras la otra es indexado 8 bits.
Parece que gdiplus no detecta correctamente como trasparente las imagenes indexadas .
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: BTNBMP using animated GIF's ?

Postby ukoenig » Wed Jun 22, 2016 11:01 am

Cristobal,

I added some more tests and all animations are working fine
Some new sets are added and working with resources.

Image

Image

1 small problem with sample 2 :
A button-animation is running as long < lRun = .T. >
Is there a way as soon closing MS-calc.exe, to set < lRun = .F.> to stop the animation ?

I tested inside the loop with
MsgAlert( IsExeRunning( "calc.exe" ) )
1. lRun starts with .F.
2. after open calc.exe lRun shows .T.
3. closing calc.exe < IsExeRunning( "calc.exe" ) > still shows .T.

Code: Select all  Expand view

FUNCTION GIF_RUN2(oBtn)
LOCAL I := 1

DO WHILE lRun = .T.
   MsgAlert( IsExeRunning( "calc.exe" ) )
   IF !IsExeRunning( "calc.exe" ) // .F. for animation break
      lRun := .F.
   ENDIF
   FOR I := 1 TO 18
      IF lRun = .F.
         EXIT
      ENDIF
      oBtn[8]:SetFile( c_path1 + "A_" + LTRIM(STR(I)) + ".gif" )
      oBtn[8]:Refresh()
      SYSWAIT(0.1)
   NEXT
ENDDO
oBtn[8]:SetFile( c_path1 + "Calc.bmp" )
oBtn[8]:Refresh()

RETURN NIL
 


regards
Uwe :?:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: BTNBMP using animated GIF's ?

Postby ukoenig » Wed Jun 29, 2016 6:52 pm

I added some more tests
New : sample using a DLL and a sample running a external EXE-file

1. I splitted the anigif to single frames
2. converted the frames to BMP
3. created a DLL
4. added the frames using numeric resource-names
5. calling the resources from inside a FOR / NEXT for the button

Image

Code: Select all  Expand view

// the DLL includes the frames from < C_1.bmp to C_12.bmp >

FUNCTION GIF_RUN4(cStyle, oBtn)
LOCAL I := 1

DO WHILE lRun = .T.
    FOR I := 1 TO 12
        IF lRun = .F.
            EXIT
        ENDIF
        oABtn[4]:SetFile( cStyle + LTRIM(STR(I)) ) // resource from DLL
        oABtn[4]:Refresh()
        SYSWAIT(0.1)
    NEXT
ENDDO
oABtn[4]:SetFile( c_path1 + "Dll.bmp" )
oABtn[4]:Refresh()

RETURN NIL
 


regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 48 guests