[q-lang-cvs] q/modules/magick/examples Makefile.am,1.2,1.3 magicktest.q,1.4,1.5
Brought to you by:
agraef
From: <ag...@us...> - 2003-12-26 03:10:52
|
Update of /cvsroot/q-lang/q/modules/magick/examples In directory sc8-pr-cvs1:/tmp/cvs-serv10788/examples Modified Files: Makefile.am magicktest.q Log Message: added image list support Index: Makefile.am =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/examples/Makefile.am,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Makefile.am 24 Dec 2003 03:05:36 -0000 1.2 --- Makefile.am 26 Dec 2003 03:10:49 -0000 1.3 *************** *** 4,9 **** if GGI ! examples_DATA = *.q *.png *.rgba endif ! EXTRA_DIST = *.q *.png *.rgba --- 4,9 ---- if GGI ! examples_DATA = *.q mozilla* endif ! EXTRA_DIST = *.q mozilla* Index: magicktest.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/examples/magicktest.q,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** magicktest.q 24 Dec 2003 03:05:36 -0000 1.4 --- magicktest.q 26 Dec 2003 03:10:49 -0000 1.5 *************** *** 1,9 **** /* $Id$ ! magicktest.q: simple magick demonstration program, shows how to render an ! image on a GGI visual */ import ggi, magick; /* display IMG: Display the given image in a GGI visual. Returns the created visual. Some examples: --- 1,11 ---- /* $Id$ ! magicktest.q: A little demonstration program, shows how to render images ! on a GGI visual. */ import ggi, magick; + /****************************************************************************/ + /* display IMG: Display the given image in a GGI visual. Returns the created visual. Some examples: *************** *** 57,62 **** interested reader. :) */ - /* Implementation. */ - /* The simple case: our image is opaque. In this case we just render it on a screen visual: */ --- 59,62 ---- *************** *** 68,72 **** where (W,H|_) = image_info IMG, VIS = ggi_open (sprintf "%s:-keepcursor" target), ! () = ggi_set_mode VIS (sprintf "%dx%d" (W,H)), PIXELS = get_image_pixels IMG (0,0) (W,H) --- 68,73 ---- where (W,H|_) = image_info IMG, VIS = ggi_open (sprintf "%s:-keepcursor" target), ! () = ggi_set_flags VIS GGI_FLAG_ASYNC || ! ggi_set_mode VIS (sprintf "%dx%d" (W,H)), PIXELS = get_image_pixels IMG (0,0) (W,H) *************** *** 86,93 **** where (W,H|_) = image_info IMG, VIS = ggi_open (sprintf "%s:-keepcursor" target), ! () = ggi_set_mode VIS (sprintf "%dx%d.A16" (W,H)), PIXELS = get_image_pixels IMG (0,0) (W,H) otherwise; /* Display driver. Assume DirectX on Windows, X11 everywhere else. */ --- 87,146 ---- where (W,H|_) = image_info IMG, VIS = ggi_open (sprintf "%s:-keepcursor" target), ! () = ggi_set_flags VIS GGI_FLAG_ASYNC || ! ggi_set_mode VIS (sprintf "%dx%d.A16" (W,H)), PIXELS = get_image_pixels IMG (0,0) (W,H) otherwise; + + /****************************************************************************/ + + /* animate IMGS: Animate a list of images. Shows each image for 1/FPS seconds, + then displays the next one. You can abort the animation at any time by + hitting a key while the mouse cursor is in the GGI window. Note that, by + default, the frame rate FPS is set to 25 which is suitable, e.g., for MPEG + movies; you might wish to change this value as needed. + + To have some fun, download yourself jurannessic_176x104.mpg from + http://www.pocketmovies.net/ and watch the little caveman discover the + cinema: + + ==> animate (read_image "jurannessic_176x104.mpg" ()) + + You can also loop the animation loop by using the `repeat' function instead + of `animate'. Sit back and watch. Enjoy. :) */ + + def FPS = 25; + + animate IMGS + + = do (show VIS) IMGS || VIS + + where (W,H|_) = image_info (hd IMGS), + VIS = ggi_open (sprintf "%s:-keepcursor" target), + () = ggi_set_flags VIS GGI_FLAG_ASYNC || + ggi_set_mode VIS (sprintf "%dx%d" (W,H)); + + repeat IMGS + + = loop VIS IMGS + + where (W,H|_) = image_info (hd IMGS), + VIS = ggi_open (sprintf "%s:-keepcursor" target), + () = ggi_set_flags VIS GGI_FLAG_ASYNC || + ggi_set_mode VIS (sprintf "%dx%d" (W,H)); + + loop VIS IMGS = do (show VIS) IMGS || sleep 2 || loop VIS IMGS; + + show VIS IMG + + = ggi_getc VIS || halt if ggi_kbhit VIS; + // *FIXME* we should really take a more decent way out here + + = ggi_put_box VIS (0,0) (W,H) PIXELS || ggi_flush VIS || sleep (1/FPS) + + where (W,H|_) = image_info IMG, + PIXELS = get_image_pixels IMG (0,0) (W,H); + + /****************************************************************************/ /* Display driver. Assume DirectX on Windows, X11 everywhere else. */ |