Usually you adjust the drawing context's scale.  Something like (untested):

(define bm (read-bitmap ...))
(define dc (send image-box get-dc))
(define t (send dc get-transformation))  ; save old scale
(send dc scale
  (/ (send image-box get-width) (send bm get-width))
  (/ (send image-box get-height) (send bm get-height)))
(send dc draw-bitmap bm 0 0)
(send dc set-transformation t)  ; restore old scale

If you want to create a new bitmap with the exact size you want, then
you create a new bitmap and use the same strategy:
(define new-bm (make-bitmap w h))
(define dc (send new-bm get-dc))
; same as above

Does that help?
Dave

On Sat, Aug 11, 2018 at 9:48 PM,  <[email protected]> wrote:
> (define image-box
>   (new canvas% [parent frame]
>        [min-width 300]
>        [min-height 300]))
>
> I'm still trying to figure out how the racket/gui library works but I'm
> having some difficulty understanding how to have an image fill a canvas.
>
> I'd like for instance to have a canvas in my gui that is 300x300 and have
> any image I load resized to fit those dimensions.
>
>                     (send (send image-box get-dc)
>                       draw-bitmap
>                       (read-bitmap (string->path (send list-box get-string
> select)))
>                       0 0))))))
>
> Here I have some quickly thrown together code for selecting a list of
> pathnames to images from a list-box.  The images are all different sizes and
> usually end up exceeding the canvas size.
>
> I've looked around the documentation, especially in the racket/draw module
> but I can't find anything beyond a "scale" which doesn't really seem all
> that helpful.  If anyone knows how to change images to certain sizes that'd
> be helpful.  I tried looking at racket/pict too but that doesn't seem to
> have anyway to absolutely set a image's dimensions.
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to