;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; DRAWS A STRING OVER AN IMAGE
;;
;; Download a medium sized quicktime trailer from apple
;; Load it into quicktime-pro and export it in a non-IFrame
;; format (gfx:get-movie-frame does not support iframes).
;; I would suggest using jpeg photo.
;;
;; This example show a few possabilities.
;; 1. A move frame can be be distorted (useing set-image-size)
;; 2. Text can be drawn to a canvas (using draw-text)
;; 3. Compositing of text and images can be done (using gfx:text2image)
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define canvas (gfx:make-canvas 600 600))
; change the path to the movie file to suit your computer
(define movie (gfx:load-movie "/tmp/myfilm.mov"))
(define mlgth (- (gfx:get-movie-duration movie) 1.0))
(define frame-length (* *second* 0.1))
(define font-style (gfx:make-text-style "Times-Roman" 120.0 (list 1.0 1.0 1.0 0.25)))
;; Note: often an image from get-movie-frame will be 24bit (i.e. no alpha channel)
;; if you want to use text2image image2image or path2image you will need a 32bit
;; image (i.e. one with an alpha channel)
;;
;; Therefore in this example we create a blank image (which will always be 32bit)
;; and draw image into the new blank image
(define loop
(lambda (time mtime)
(let ((image (gfx:get-movie-frame movie mtime))
(new (gfx:make-image 600 600)))
(gfx:image2image image new 1 '(0 0 600 600))
(gfx:text2image (number->string mtime) new font-style '(10 0))
(gfx:draw-image time canvas new 1.0)
(set! time (+ time frame-length))
(if (< mtime mlgth)
(callback (- time 4000) 'loop time (+ mtime 0.1))))))
(loop (now) 0.0)
; the loop will stop when the end of the movie is reached