disable (minimize?) smoothing for `draw-bitmap' in 'unsmoothed mode
This commit is contained in:
parent
cd34760a33
commit
e921f20b6a
|
@ -100,6 +100,8 @@
|
|||
get-size
|
||||
get-transformation
|
||||
set-transformation
|
||||
get-smoothing
|
||||
set-smoothing
|
||||
scale
|
||||
get-font)
|
||||
|
||||
|
@ -163,10 +165,13 @@
|
|||
[(make-or-false bitmap%) [mask #f]])
|
||||
(let ([sx (if (zero? src-w) 1.0 (/ dest-w src-w))]
|
||||
[sy (if (zero? src-h) 1.0 (/ dest-h src-h))])
|
||||
(let ([t (get-transformation)])
|
||||
(let ([t (get-transformation)]
|
||||
[s (get-smoothing)])
|
||||
(scale sx sy)
|
||||
(when (eq? s 'unsmoothed) (set-smoothing 'aligned))
|
||||
(begin0
|
||||
(draw-bitmap-section src (/ dest-x sx) (/ dest-y sy) src-x src-y src-w src-h style color mask)
|
||||
(when (eq? s 'unsmoothed) (set-smoothing 'unsmoothed))
|
||||
(set-transformation t)))))
|
||||
|
||||
(def/override (get-char-width)
|
||||
|
|
|
@ -1634,12 +1634,17 @@
|
|||
[a-src-y (floor src-y)]
|
||||
[a-msrc-x (floor msrc-x)]
|
||||
[a-msrc-y (floor msrc-y)]
|
||||
[adjust-pattern-filter
|
||||
(lambda (p)
|
||||
(when (eq? smoothing 'unsmoothed)
|
||||
(cairo_pattern_set_filter p CAIRO_FILTER_NEAREST)))]
|
||||
[stamp-pattern
|
||||
(lambda (src a-src-x a-src-y)
|
||||
(let ([p (cairo_pattern_create_for_surface (send src get-cairo-alpha-surface))]
|
||||
[m (make-cairo_matrix_t 0.0 0.0 0.0 0.0 0.0 0.0)])
|
||||
(cairo_matrix_init_translate m (- a-src-x a-dest-x) (- a-src-y a-dest-y))
|
||||
(cairo_pattern_set_matrix p m)
|
||||
(adjust-pattern-filter (cairo_get_source cr))
|
||||
;; clip to the section that we're supposed to draw:
|
||||
(cairo_save cr)
|
||||
(when op (cairo_set_operator cr op))
|
||||
|
@ -1663,6 +1668,7 @@
|
|||
(send src get-cairo-surface)
|
||||
(- a-dest-x a-src-x)
|
||||
(- a-dest-y a-src-y))
|
||||
(adjust-pattern-filter (cairo_get_source cr))
|
||||
(if mask
|
||||
(stamp-pattern mask a-msrc-x a-msrc-y)
|
||||
(begin
|
||||
|
|
|
@ -410,4 +410,13 @@
|
|||
CAIRO_PATTERN_TYPE_LINEAR
|
||||
CAIRO_PATTERN_TYPE_RADIAL)
|
||||
|
||||
(define-enum
|
||||
0
|
||||
CAIRO_FILTER_FAST
|
||||
CAIRO_FILTER_GOOD
|
||||
CAIRO_FILTER_BEST
|
||||
CAIRO_FILTER_NEAREST
|
||||
CAIRO_FILTER_BILINEAR
|
||||
CAIRO_FILTER_GAUSSIAN)
|
||||
|
||||
(define/provide CAIRO_CONTENT_COLOR_ALPHA #x3000)
|
||||
|
|
|
@ -41,13 +41,10 @@ Creates a new memory DC. If @racket[bitmap] is not @racket[#f], it is
|
|||
|
||||
The same as @method[dc<%> draw-bitmap-section], except that
|
||||
@racket[dest-width] and @racket[dest-height] cause the DC's
|
||||
transformation to be adjusted while drawing the bitmap so
|
||||
that the bitmap is scaled.
|
||||
|
||||
In older versions, this method smoothed drawing more than
|
||||
@method[dc<%> draw-bitmap-section], but smoothing is now provided by
|
||||
@method[dc<%> draw-bitmap-section].
|
||||
}
|
||||
transformation to be adjusted while drawing the bitmap so that the
|
||||
bitmap is scaled; and, if the DC's smoothing mode is
|
||||
@racket['unsmoothed], it is changed to @racket['aligned] while
|
||||
drawing.}
|
||||
|
||||
@defmethod[(get-argb-pixels [x real?]
|
||||
[y real?]
|
||||
|
|
Loading…
Reference in New Issue
Block a user