GifDecoder module (All OS, single frame & animated gifs)

Share your advanced PureBasic knowledge/code with the community.
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2056
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: GifDecoder module (All OS, single frame & animated gifs)

Post by Andre »

Nice, thank you for the possibility of an easy and proper GIF display in PB! :D
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: GifDecoder module (All OS, single frame & animated gifs)

Post by Kwai chang caine »

Image
You are wonderfull !!

1/ My sheep leaps now like a gazelle, with the value 100 :mrgreen:

2/ The last GIF not crush the JPG thanks to the two parameters.
I have replace

Code: Select all

KillThread(*PtrAnimate\ThreadID)
by

Code: Select all

*PtrAnimate\Quit = #True
*PtrAnimate\Target = 0
Just i allowed myself to massacre your work by adding :oops:

Code: Select all

If IsGadget(Target)
      SetGadgetState(Target, Image)
     EndIf 
Because i have sometime red line..



And nooooowwwww...ladies and gentlemaaaaaaaan !!!!

All works fiiiine !!!

Image

Before you are my champion of HieroGlyph, now you are also my champion of HieroGIF :D

Thanks a lot for the mountain of work you have do, for all the littles animated and sympathetics personages 8) 8)
Image

I wish you a very good animated day !!!
ImageThe happiness is a road...
Not a destination
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: GifDecoder module (All OS, single frame & animated gifs)

Post by wilbert »

Glad to help out :wink:

You keep amazing me with the amount of animated gifs you have :shock:
Kwai chang caine wrote:Just i allowed myself to massacre your work by adding :oops:

Code: Select all

If IsGadget(Target)
      SetGadgetState(Target, Image)
     EndIf 
I didn't get such error myself but an extra check does no harm so I added the gadget check to the module code in the first post.
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: GifDecoder module (All OS, single frame & animated gifs)

Post by Kwai chang caine »

You keep amazing me with the amount of animated gifs you have
It's my passion :D
Since the begining, at the moment of i see my first, i fall in love immediately ahead his beautiful body :mrgreen:
Image
The GIF are nices, funny and tireless....like KCC :lol:

And with the come of the 3D
Image
this time i found them
ImageSPLENDID !!!

Now...you are also in my collection...one GIF more :mrgreen:
Image
I didn't get such error myself but an extra check does no harm so I added the gadget check to the module code in the first post.
It's when i jump between JPG and GIF in the same imageGadget, perhaps an error of me :oops:

Thanks to you...i have modify my little manager of GIF linker, who not works very well with WebGadget and ListIcon, to replace by WebGadget and ImageGadget
And all my babies can come to home, for be ready for the futur thread of forum 8)

Before selected GIF

Image


After selected GIF

Image

Have a very good day GIFMASTER 8)
ImageThe happiness is a road...
Not a destination
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: GifDecoder module (All OS, single frame & animated gifs)

Post by J. Baker »

Resizable Gifs by Gadget size no matter the DPI. :D
  • "Enable Dpi aware executable" in the compiler options.
  • Add to line 369, "DPI.f = DesktopResolutionX()" in Module.
  • Add to line 463, "ResizeImage(\image, GadgetWidth(*Animation\Target) * DPI, GadgetHeight(*Animation\Target) * DPI)" in Module.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
User avatar
mk-soft
Always Here
Always Here
Posts: 5333
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: GifDecoder module (All OS, single frame & animated gifs)

Post by mk-soft »

Short information.

The decoder has been integrated into PB for a long time

Code: Select all

UseGIFImageDecoder()
Update pb example

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - ImagePlugin GIF Viewer example file
;
;    (c) Fantaisie Software
;    
;    Modify example by mk-soft - Upscale gif images
;
; ------------------------------------------------------------
;

; Enable the GIF decoder
UseGIFImageDecoder()

; Loading a GIF file
If LoadImage(0, #PB_Compiler_Home+"Examples/Sources/Data/PureBasicLogo.gif")
  
  dx = ImageWidth(0)
  dy = ImageHeight(0)
  
  OpenWindow(0, 100, 100, dx, dy, "GIF viewer")
  
  CanvasGadget(0, 0, 0, dx, dy)
  
  ; Upscale
  dx = DesktopScaledX(dx)
  dy = DesktopScaledY(dy)
  
  ; Add a timer to animate the GIF, starts immediately to display the first frame witout delay
  AddWindowTimer(0, 0, 1)
 
  Repeat
    Event = WaitWindowEvent()
   
    If Event = #PB_Event_Timer
      SetImageFrame(0, Frame)
     
      ; Each GIF frame can have its own delay, so change the timer accordingly
      ;
      RemoveWindowTimer(0, 0)
      AddWindowTimer(0, 0, GetImageFrameDelay(0))
     
      If StartDrawing(CanvasOutput(0))
        DrawImage(ImageID(0), 0, 0, dx, dy)
        StopDrawing()
      EndIf
      
      ; Go to next frame
      Frame+1
      If Frame >= ImageFrameCount(0) ; Cycle back to first frame, to play in loop
        Frame = 0
      EndIf
    EndIf
   
  Until Event = #PB_Event_CloseWindow
Else
  Debug "Impossible to load the file: " + Filename$
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
jacdelad
Addict
Addict
Posts: 1431
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: GifDecoder module (All OS, single frame & animated gifs)

Post by jacdelad »

Is it exactly this decoder or a different one?
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
User avatar
J. Baker
Addict
Addict
Posts: 2178
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Re: GifDecoder module (All OS, single frame & animated gifs)

Post by J. Baker »

Wilberts code runs Gifs with High DPI much faster and smooth. PureBasic's method stutters here with High DPI. Debugger is off for both, of course.

EDIT: It's the CanvasGadget() that is slow. Rendering on WindowOutput() is much better.
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef

Mac: 10.13.6 / 1.4GHz Core 2 Duo / 2GB DDR3 / Nvidia 320M
PC: Win 7 / AMD 64 4000+ / 3GB DDR / Nvidia 720GT


Even the vine knows it surroundings but the man with eyes does not.
Post Reply