[racket] displaying images frame by frame in the same window in Racket

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Jul 10 05:20:10 EDT 2014

At Wed, 9 Jul 2014 15:02:09 +0530, Animesh Pandey wrote:
> I have three small images of same size. I want to display them one
> after another.

I'm not completely sure of your goal, but I think you probably meant to
send `bird-bitmap` to `draw-bitmap-section` in each step.

One way way to add to the old display is to send `set-label` to the
message that you create for the first step, instead of adding new
messages.

Also, I recommend using `sleep/yield` instead of `sleep` to pause, so
that the GUI will be responsive while paused.

----------------------------------------

(define new1-bitmap
  (make-bitmap
   (send bird-bitmap get-width)
   (send bird-bitmap get-height)))

(define dc-crop
  (new bitmap-dc% [bitmap new1-bitmap]))

(define f-crop
  (new frame% [label "Random"]))
(send f-crop show #t)

(send dc-crop draw-bitmap-section
      bird-bitmap
      0
      0
      0
      (round(* (/ (send bird-bitmap get-height) 3) 2))
      (send bird-bitmap get-width)
      (round(/ (send bird-bitmap get-height) 3)))
(define m
 (new message% [parent f-crop] [label new1-bitmap]))
(sleep/yield 3)
(send dc-crop draw-bitmap-section
      bird-bitmap
      0
      (round(/ (send bird-bitmap get-height) 3))
      0
      (round(/ (send bird-bitmap get-height) 3))
      (send bird-bitmap get-width)
      (round(/ (send bird-bitmap get-height) 3)))
(send m set-label new1-bitmap)
(sleep/yield 3)
(send dc-crop draw-bitmap-section
      bird-bitmap
      0
      (* 2 (round(/ (send bird-bitmap get-height) 3)))
      0
      0
      (send bird-bitmap get-width)
      (round(/ (send bird-bitmap get-height) 3)))
(send m set-label new1-bitmap)


Posted on the users mailing list.