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-size
|
||||||
get-transformation
|
get-transformation
|
||||||
set-transformation
|
set-transformation
|
||||||
|
get-smoothing
|
||||||
|
set-smoothing
|
||||||
scale
|
scale
|
||||||
get-font)
|
get-font)
|
||||||
|
|
||||||
|
@ -163,10 +165,13 @@
|
||||||
[(make-or-false bitmap%) [mask #f]])
|
[(make-or-false bitmap%) [mask #f]])
|
||||||
(let ([sx (if (zero? src-w) 1.0 (/ dest-w src-w))]
|
(let ([sx (if (zero? src-w) 1.0 (/ dest-w src-w))]
|
||||||
[sy (if (zero? src-h) 1.0 (/ dest-h src-h))])
|
[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)
|
(scale sx sy)
|
||||||
|
(when (eq? s 'unsmoothed) (set-smoothing 'aligned))
|
||||||
(begin0
|
(begin0
|
||||||
(draw-bitmap-section src (/ dest-x sx) (/ dest-y sy) src-x src-y src-w src-h style color mask)
|
(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)))))
|
(set-transformation t)))))
|
||||||
|
|
||||||
(def/override (get-char-width)
|
(def/override (get-char-width)
|
||||||
|
|
|
@ -1634,12 +1634,17 @@
|
||||||
[a-src-y (floor src-y)]
|
[a-src-y (floor src-y)]
|
||||||
[a-msrc-x (floor msrc-x)]
|
[a-msrc-x (floor msrc-x)]
|
||||||
[a-msrc-y (floor msrc-y)]
|
[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
|
[stamp-pattern
|
||||||
(lambda (src a-src-x a-src-y)
|
(lambda (src a-src-x a-src-y)
|
||||||
(let ([p (cairo_pattern_create_for_surface (send src get-cairo-alpha-surface))]
|
(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)])
|
[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_matrix_init_translate m (- a-src-x a-dest-x) (- a-src-y a-dest-y))
|
||||||
(cairo_pattern_set_matrix p m)
|
(cairo_pattern_set_matrix p m)
|
||||||
|
(adjust-pattern-filter (cairo_get_source cr))
|
||||||
;; clip to the section that we're supposed to draw:
|
;; clip to the section that we're supposed to draw:
|
||||||
(cairo_save cr)
|
(cairo_save cr)
|
||||||
(when op (cairo_set_operator cr op))
|
(when op (cairo_set_operator cr op))
|
||||||
|
@ -1663,6 +1668,7 @@
|
||||||
(send src get-cairo-surface)
|
(send src get-cairo-surface)
|
||||||
(- a-dest-x a-src-x)
|
(- a-dest-x a-src-x)
|
||||||
(- a-dest-y a-src-y))
|
(- a-dest-y a-src-y))
|
||||||
|
(adjust-pattern-filter (cairo_get_source cr))
|
||||||
(if mask
|
(if mask
|
||||||
(stamp-pattern mask a-msrc-x a-msrc-y)
|
(stamp-pattern mask a-msrc-x a-msrc-y)
|
||||||
(begin
|
(begin
|
||||||
|
|
|
@ -410,4 +410,13 @@
|
||||||
CAIRO_PATTERN_TYPE_LINEAR
|
CAIRO_PATTERN_TYPE_LINEAR
|
||||||
CAIRO_PATTERN_TYPE_RADIAL)
|
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)
|
(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
|
The same as @method[dc<%> draw-bitmap-section], except that
|
||||||
@racket[dest-width] and @racket[dest-height] cause the DC's
|
@racket[dest-width] and @racket[dest-height] cause the DC's
|
||||||
transformation to be adjusted while drawing the bitmap so
|
transformation to be adjusted while drawing the bitmap so that the
|
||||||
that the bitmap is scaled.
|
bitmap is scaled; and, if the DC's smoothing mode is
|
||||||
|
@racket['unsmoothed], it is changed to @racket['aligned] while
|
||||||
In older versions, this method smoothed drawing more than
|
drawing.}
|
||||||
@method[dc<%> draw-bitmap-section], but smoothing is now provided by
|
|
||||||
@method[dc<%> draw-bitmap-section].
|
|
||||||
}
|
|
||||||
|
|
||||||
@defmethod[(get-argb-pixels [x real?]
|
@defmethod[(get-argb-pixels [x real?]
|
||||||
[y real?]
|
[y real?]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user