Animations

Just starting out? Need help? Post your questions and find answers here.
RedmoonX
User
User
Posts: 26
Joined: Mon Jan 17, 2005 9:54 am
Location: Sweden
Contact:

Animations

Post by RedmoonX »

is there any way to use GIF images to make animations

ir must u display differrent images

like show image1 then image2 then image 3

RedmoonX
^^
-
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

What about using a WebGadget to display a animated .GIF.

Code: Select all

Enumeration 
  #GIF_0 
EndEnumeration 
Procedure myGIFGadget(id, x, y, gif$) 
  If FileSize(gif$) > 0 
    ; --> Read gif file to get width and height 
    ReadFile(0, gif$) 
    FileSeek(6) 
    gifWidth = ReadWord() 
    gifHeight = ReadWord() 
    CloseFile(0) 
    ; --> Create a javaScript URL to load the GIF image 
    js$ = "javascript:document.write('<html><head><title></title></head>" 
    ; --> Remove scrollbars 
    js$ + "<body  topmargin=0 leftmargin=0 scroll=" + Chr(34) + "no" + Chr(34) + ">" 
    ; --> Our image source is here 
    js$ + "<img src=" + Chr(34) + gif$ + Chr(34) + "></body></html>')" 
    ; --> Fix path$ 
    url$ = ReplaceString(js$, "\", "\\") 
    ; --> Reize the WebGadget to image size 
    ResizeGadget(id, -1, -1, gifWidth, gifHeight) 
    ; --> Load the JavaScript URL into WebGadget 
    SetGadgetText(id, url$) 
  EndIf 
EndProcedure 
If OpenWindow(0, 0, 0, 600, 400, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Gif display") And CreateGadgetList(WindowID(0)) 
  ; --> Create a blank WebGadget 
  WebGadget(#GIF_0, 0, 0, 0, 0, "about:blank") 
  ; --> You can remove the OpenFileRequester 
  ; --> And replace it with the path To your GIF 
  ; --> myGIFGadget(WebGadget#, xPos, yPos, imagePath$) 
  myGIFGadget(#GIF_0, 0, 0, OpenFileRequester("Choose image for myGIFGadget #0", "c:\",  "Gif file | *.Gif", 0)) 
  Repeat 
    event = WaitWindowEvent() 
  Until event = #PB_Event_CloseWindow 
EndIf 
End 
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
porfirio
Enthusiast
Enthusiast
Posts: 111
Joined: Mon Nov 15, 2004 11:00 pm
Location: portugal

Post by porfirio »

I try it and it is cool but will be more cool if some one know how to desable right click menu and left move to copy image <

that could be made with javasrcipt (i don't know how) and it will be awesome if you could make it transparent mabe some class to make the webgadgect transparent?

that will be cool
Forgive-me for my english, i'm portuguese!
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> how to desable right click menu

viewtopic.php?t=3817

Please use the search function here. :)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Thanks to PB for the link to his code. :)

I've revised my code from above and used some of PB's code example and came up with this. You can also change the color of the WebGadget background to help with tranparent .GIF's.

Code: Select all

; *****       Sparkies GIF display        *****
; Portions of code produced by fellow PB'er "PB"
Enumeration
  #GIF_0
EndEnumeration
Procedure myGIFGadget(id, x, y, bg$, gif$)
  If FileSize(gif$) > 0
    ; --> Read GIF file to get width and height
    ; --> This is used to resize the webgadget to fit the GIF
    ReadFile(0, gif$)
    FileSeek(6)
    gifWidth = ReadWord()
    gifHeight = ReadWord()
    CloseFile(0)
    ; --> Create blank HTML page to load the GIF image
    url$ = "about:<html>"
    ; --> Remove margins and scrollbars
    url$ + "<body bgcolor= '#" + bg$ + "' topmargin=0 leftmargin=0 scroll='no'>"
    ; --> Our image source is here
    url$ + "<img src='" + gif$ + "'></body></html>')"
    ; --> Greate the GIF/WebGadget
    WebGadget(id, x, y, gifWidth, gifHeight, url$)
    ; --> No mouse clicks accepted
    DisableGadget(id, 1)
  EndIf
EndProcedure
If OpenWindow(0, 0, 0, 600, 400, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Gif display") And CreateGadgetList(WindowID(0)) 
  ; --> Set background color for webgadget
  bgColor$ = Hex(RGB(224, 223, 227))
  ; --> You can remove the OpenFileRequester
  ; --> And replace it with the path To your GIF
  ; --> myGIFGadget(WebGadget#, xPos, yPos, bgColor, imagePath$)
  myGIFGadget(#GIF_0, 10, 10, bgColor$, OpenFileRequester("Choose image for myGIFGadget #0", "c:\",  "Gif file | *.Gif", 0))
  Repeat
    event = WaitWindowEvent()
  Until event = #PB_Event_CloseWindow 
EndIf 
End

What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply