Silverfrost Forums

Welcome to our forums

GIF animation

20 Sep 2012 10:17 #10740

Do anyone have PCX/GIF animation program written in Clearwin? I have one written 15 years ago but when i compile it now it does not work anymore. It was written by dumbest complex way using all common blocks from huge hydrocode which now are completely changed plus i do not find such functions like PCX_TO_SCREEN_BLOCK, also program uses DOS program ALCHEMY to transform and resize files etc -- total darkness...it's easier to kill it and rewrite it from zero then fix it.

If you do not have one, then may be you will suggest how you'd write it? Just simplest skeleton how you think best way to write it is appreciated, like this

  • after opening clearwin graphics window read all files ending with 'gif' (i suppose it's using files@). Files i have are called something like this a001.gif, a002.gif ....
  • make a cycle which visualizes them listening keyboard input to stop/continue/ accelerate/decelerate animation
22 Sep 2012 3:49 #10744

winio@('%gi[...]') provides one approach where the animation is built into a GIF resource file.

23 Sep 2012 9:13 #10746

Dan, Paul,

To make an animated GIF you need the appropriate software, but that does seem to me to be the answer if the animation takes up a small area of the screen, and is the same every time the program is run - like files going into the waste paper basket and such gimmicks.

The do it yourself approch could have a series of GIFs (or any other file format) drawn on top of each other. I suspect timing is vital. I have an initial splash screen that fades away using a SetWindowOpacity routine that was posted on this forum, and I discovered that to fade down the image in 2 seconds was as long as I could tolerate, and as this occurred in 255 steps, the rate was then 127 steps per second, set with a %dl.

To overlay the files, I would set up a %gr area, and use IMPORT_IMAGE@ in a callback to a %dl format code. I see that the latest version of FTN95 has proper support for the GIF format in IMPORT_IMAGE@ and IMPORT_GIF@. It isn't necessary to overlay the images over the whole %gr, just the parts that change. I suppose I would use images in my RESOURCES for speed, rather than loading them from disk one at a time, if it was the same animation run every time.

As well as timing, getting them in the right order is an issue if they are loaded from named files (generated as output from some other program), and also the animation will stutter if there is a lot going on in a computer at the same time. While there is a lot to be said about reading and storing all the files before starting to display them, if they were simple bitmaps, I don't think I would bother with copying to and from DIBs, instead I would use the painter's algorithm and just keep importing the images into the %gr area.

Eddie

25 Sep 2012 10:55 #10758

I need both. Sometimes your custom animator is needed to be paused, stopped, and go back on specific frame etc. I've done that with PCX using Clearwin and it was useful. I showed such animations on the conferences, and when people have questions it is important to have full control of animation. With current support of GIF all can be done even more efficiently.

I've used also someones GIF animation programs but don't have them anymore. Which GIF animator program you know is good ?

25 Sep 2012 6:11 #10759

Dan,

Many years ago I used Graphics Workshop from Alchemy Mindworks. To my surprise they are still in business, and trading at http://www.mindworkshop.com/. It's try before you buy...

Eddie

27 Sep 2012 12:08 #10766

Thanks all for suggestions.

P.S. Oct 07 2012

By the way i've tried PhotoScape and like it. Surprised it is completely free, i do not know how these people survive, unless they operate on photosynthesis and solar power. LOL.

It has absolutely intuitive GIF animator as one of the options. You just drag-and-drop GIF files and save the result. Behind the hood i even did not look - it has soooo many options if anyone needs them.

I'd still encourage Clearwin+ fans to write GIF player and post the source here. Just don't have time to do that myself

14 Nov 2012 10:12 #11048

Quoted from DanRRight

I'd still encourage Clearwin+ fans to write GIF player and post the source here. Just don't have time to do that myself

I found a C# snippet for writing animated gifs. Based on that I wrote a module in Component Pascal for animated gif creation.

Currently it can scan all image files in a directory, sort them alphabetically, scale images to desired size and write animated gif from them. I also created a simple window form to play gif animation, so finished animated gif can be previewed.

These routines can be called from FTN95 Clearwin+ program.

I will clean up some stuff, add exception handling and put sources and DLL's available for download.

16 Nov 2012 11:07 #11070

That would be great, thanks for efforts.

17 Nov 2012 9:06 #11080

Quoted from DanRRight That would be great, thanks for efforts.

Simple FTN95 callable animated GIF creator available here for testing.

The example project reads source image files from the 'in' directory and then outputs the animated target GIF files into the 'out' directory.

Let me know, if you find bugs. I will try to add simple Clearwin+ front end and then put all sources available.

18 Nov 2012 5:03 #11081

It works. Produces visible squares in dark areas though for large JPG files and sometimes a lot of noise in grayish areas probably trying to find the best 8bit color for 24bit original. But for some specific contents all looks fine

Does your program take GIF files for input or only JPG? Things are that JPG is typically compressed lossy format, so people in science and engineering do not use it for animation purposes because it will show spontaneous noise on the wide slowly changing color areas which is specifically visible when scaling image size.

18 Nov 2012 9:13 #11083

Quoted from DanRRight

Does your program take GIF files for input or only JPG? Things are that JPG is typically compressed lossy format, so people in science and engineering do not use it for animation purposes because it will show spontaneous noise on the wide slowly changing color areas which is specifically visible when scaling image size.

It seem's to work with some GIF formatted files, but not all of them.

Currently I just simply use .NET's Bitmap Class to read the image data and dumb the data in GIF image format into a buffer.

You should also be able to use: PNG, BMP and TIFF images as source files.

18 Nov 2012 2:06 #11084

Great. When and if you will be making Clearwin shell to it please look at the implementation of Photoscape GIF animator - everything done just by simple clicks and drag and drops, no single instance of typing. And if Paul some day implement the template for such resizable sub-windows Clearwin misssing very much our programs would look very professionally !

18 Nov 2012 3:34 #11085

Quoted from DanRRight

When and if you will be making Clearwin shell to it please look at the implementation of Photoscape GIF animator - everything done just by simple clicks and drag and drops, no single instance of typing.

I was thinking about a simple Clearwin+ user interface for the first version. Maybe use parameter box for animated GIF creation parameters and some buttons attached to directory browser dialog for selecting input and ouput directories. Simple and a nice addition would be to allow source image directory to be selected using drag and drop.

Feel free to help with the user interface creation! 😉

I have added simple image file validation for source images, so wrongly formatted images should now be handled gracefully.

18 Nov 2012 4:42 #11086

Dan,

I am not sure what you are looking for but here is some old code that implements a MDI sample...

      winapp
c--------------------------------------------------------------
      include <windows.ins>
      integer i,c0,c1,c2,h1,h2,cwh1
      logical L
      common h1,h2
      external child_func

      i=winio@('%ww[no_border]%ca[MDI frame]&')
      i=winio@('%mn[&Child]&',child_func)
      i=winio@('%pv%fr&',400,400)
      i=winio@('%lw',c0)

      i=winio@('%aw&',c0)
      i=winio@('%ww[no_border]%ca[First Child]&')
      i=winio@('%sm[&Child]&',child_func)
      i=winio@('%pv%30.3`cw[hscroll,vscroll]&',7,cwh1)
      i=winio@('%lw&',c1)
      i=winio@('%hw',h1)

      call set_max_lines@(cwh1,50L)
      write(7,*) 'Hello there!'

      i=winio@('%aw&',c0)
      i=winio@('%ww[no_border]%ca[Second Child]&')
      i=winio@('%pv%gr[black,metafile_resize]&',200,200)
      i=winio@('%lw&',c2)
      i=winio@('%hw',h2)

      call ellipse@(100,100,50,50,14)
      L=BringWindowToTop(h1)

      end

C--------------------------------------------
      integer function child_func()
      include <clearwin.ins>

      integer h,hh,i
      integer h1,h2
      common h1,h2

      h=clearwin_info@('FOCUS_WINDOW')
      hh=0
      if(h.eq.h1) hh=1
      if(h.eq.h2) hh=2
      if(hh.gt.0) then
        i=winio@('Window %wd is active %2nl%cn%`7bt[OK]',hh)
      endif

      child_func=1
      end
18 Nov 2012 4:46 #11087

Again, here is some old code for drag and drop but I find that it needs a kick start under Windows 7. To kick start I disable/re-enable drag-and-drop from the Windows 8 Start menu.

       winapp
c---------------------------------------------------
       integer i,winio@,x,y
       external drop_func
       character*100 filename
       common filename,x,y
       filename=' '
       i=winio@('%ca[Drag and drop]Dropped file:&')
       i=winio@('%gp&',x,y)
       i=winio@('%dr&',drop_func)
       i=winio@('%2nl%60st',filename)       
       end
c --------------------------------------------------
       integer function drop_func()
       include <clearwin.ins>
       character*100 filename
       integer i,x,y
       common filename,x,y
       filename(1:100)=clearwin_string@('DROPPED_FILE')
       call window_update@(filename)
       i=winio@('%sp%ww[naked]%cn%8tt[Pause]',x+5,y-5)
       drop_func=1 
       end
18 Nov 2012 8:20 #11088

Thanks for examples,

My first version will support only scanning for source images in selected format and from selected source directory. Source images are alphabetically sorted before being written into animated GIF file. I may later add more sophisticated control for source images and animation frames.

My current prototype looks like this

I still need to glue some 'bolts and nuts' together, but basic interface is allready working including simple drag and drop support.

19 Nov 2012 5:56 #11091

No, these are independent windows in your example, Paul. Here what i mean. It's like resizable ob/cb. Several panels share the same area but you can increase and decrease their share with mouse

http://img266.imageshack.us/img266/8397/stackresizable.jpg

19 Nov 2012 8:35 #11094

This (i.e. docking windows) is not something I could contempt providing within ClearWin+, at least not at the moment. If anyone wants to take this up as a challenge, there is enough functionality already available for users to do this for themselves given time and patience.

19 Nov 2012 10:10 #11097

All compilers GUI are implemented via docking windows. SDBG would look much neater with them too...miss them very much.

20 Nov 2012 10:07 #11123

I hit the wall while using Clearwin+ for the user interface. When I call a .NET routine from the callback, it works for the first time. A second call to the callback always kills the program with memory violation exception. When using some .NET class, there seems to be multiple threads running and I suspect this to be the cause for the exception.

As a result, I decided to create a .NET Form based user interface. Maybe it's a good time to try using Visual Clearwin? 😃

I have updated my files and added the Component Pascal source for the AnimGif.dll into AnimGif_dll directory. Available here

Please login to reply.