[racket] Smoothing in 5.1.1 Racket Device Contexts (Ubuntu Lucid Lynx, Gnome)

From: J. Vincent Toups (vincent.toups at gmail.com)
Date: Tue Jun 28 19:43:13 EDT 2011

Hi Racket Users,

Anyone else noticed that device contexts always smooth, regardless of
whether they are bitmap or canvas dcs and regardless of what you have
passed to the message `set-smoothing`.

On my system, the function

(require racket/match

(define (scale-bitmap bitmap . args)
  (match args
    [(list scale)
     (scale-bitmap bitmap scale scale)]
    [(list scale-x scale-y)
     (let* ((w (send bitmap get-width))
            (h (send bitmap get-height))
            (new-w (* scale-x w))
            (new-h (* scale-y h))
            (target (make-object bitmap% new-w new-h #f #t))
            (target-dc (new bitmap-dc% [bitmap target])))
       (send target-dc set-smoothing 'unsmoothed)
       (send target-dc set-scale scale-x scale-y)
       (send target-dc draw-bitmap bitmap 0 0)

Returns an appropriately scaled bitmap, but it is smoothed.  You can
move that call to set-smoothing anywhere you want without getting the
right behavior.  I've poked around in the sources a bit, but can't see
anything obviously out of whack, but its a lot of calls out to cairo.

Any ideas?

(This is my first post, by the way - hope I'm doing everything right?)


Posted on the users mailing list.