Skip to content

Instantly share code, notes, and snippets.

@thomcc
Created December 21, 2011 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomcc/1507796 to your computer and use it in GitHub Desktop.
Save thomcc/1507796 to your computer and use it in GitHub Desktop.
show an image snip on a canvas in a new frame
#lang racket/gui
(define (show-image-snip-in-new-frame snip)
(define bmp (send snip get-bitmap))
(define f (new frame% [label "image snip"]
[width (send bmp get-width)]
[height (send bmp get-height)]))
(define c
(new canvas%
[paint-callback (λ (c dc) (send dc draw-bitmap bmp 0 0))]
[parent f]))
(send f show #t))
(require plot)
(show-image-snip-in-new-frame (plot (function sin (- pi) pi #:label "y = sin(x)")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment