Re: [racket-users] Bitmaps and Canvas sizes

2018-08-12 Thread silverfire675
That works perfectly,  thanks David!

(define (resize-draw canvas0 bm)
  (let* ((dc (send canvas0 get-dc))
 (t (send dc get-transformation)))
(send dc scale
  (/ (send canvas0 get-width) (send bm get-width))
  (/ (send canvas0 get-height) (send bm get-height)))
(send dc draw-bitmap bm 0 0)
(send dc set-transformation t)))



On Saturday, August 11, 2018 at 10:36:16 PM UTC-4, david.vanderson wrote:
>
> 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,  > 
> 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 racket-users...@googlegroups.com . 
> > 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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Bitmaps and Canvas sizes

2018-08-11 Thread silverfire675
(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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Windows Foreign Libraries

2018-03-23 Thread silverfire675
Really silly question but I was using the rsvg package with racket/gui on 
Linux and everything was working fine.   I moved the code over to windows 
to try it out (after installing the rsvg package there) and it's 
complaining that librsvg-2.2.dll is missing.   I've now tried two separate 
.dll files in my code directory (one that was from the official gnome ftp) 
and racket throws an error that ($1 is not a valid Win32 application) when 
trying to call (ffi-lib) on it.

Now I'm going to try building the .dll myself,  but I'm wondering if it's 
possible after I've got a .dll that works if you can somehow connect it 
with the rsvg package so when I compile for distribution in DrRacket it 
automatically includes the .dll I have.  It pretty much already does this 
for all the other gnome libraries racket/gui uses, and it'd be much easier 
than having to manually add it to the libs after it's done compiling.


-- 
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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.