@ajaybatta54 has joined the channel
If I have a bitmap pict and I scale it, it appears that the pict is blurred/smoothed if I scale it. Is there a way to not have this behavior?
Also if you scale it by a factor of exact 2 ?
Hmm I was scaling it by exact 4
Same thing.
Just checking :slightly_smiling_face:
There must be an option somewhere.
I thought there was a parameter to control it. But I’m drawing a blank
Is it a png?
Yes.
It’s a bitmap-section copy of a png
So a simple (scale 4 (bitmap “foo.png”)) ?
More like (scale (bitmap (copy-bitmap-section (read-bitmap “foo.png”) 0 0 96 96)) 4)
copy-bitmap-section
creates a new bitmap and uses draw-bitmap-section
on it
Can’t find it in the docs.
It’s local to my code: (define (copy-bitmap-section src src-x src-y width height)
(define new-bitmap (make-bitmap width height))
(define new-bitmap-dc (send new-bitmap make-dc))
(send new-bitmap-dc draw-bitmap-section
src 0 0 src-x src-y width height)
new-bitmap)
I see it too.
I think I see it without the copy-bitmap-section too.
(scale (bitmap bm) 8 )
Yeah, just wanted to make sure I wasn’t mucking it up
Let’s see what happens if we scale it without using scale
.
The insides of the scale adjuster seems straightforward: https://github.com/racket/pict/blob/master/pict-lib/pict/private/utils.rkt#L1178
(define (scaled-bitmap src k)
(define w (send src get-width))
(define h (send src get-height))
(define new-bitmap (make-bitmap (* k w) (* k h)))
(define new-bitmap-dc (send new-bitmap make-dc))
(send new-bitmap-dc set-scale k k)
(send new-bitmap-dc draw-bitmap src 0 0)
new-bitmap)
I feel like I may need to smuggle a set-smoothing
into the scaling …
Looks crisper.
Cool.
Weird. I have a smoothed
and an aligned
in metapict, but no unsmoothed
.
In DrRacket: > (dc (lambda (dc x0 y0)
(displayln (send dc get-smoothing)))
10 10)
unsmoothed
aligned
;; unsmoothed : pict -> pict
;; Produces a pict like `p`, but that always draws in 'unsmoothed mode
(define (unsmoothed p)
; (define draw-p (make-pict-drawer p))
(def p2
(dc (lambda (dc x y)
(def s (send dc get-smoothing))
(send dc set-smoothing 'unsmoothed)
; (draw-p dc x y)
(draw-pict p dc x y)
(send dc set-smoothing s))
(pict-width p)
(pict-height p)))
(make-pict (pict-draw p2)
(pict-width p)
(pict-height p)
(pict-ascent p)
(pict-descent p)
(list (make-child p 0 0 1 1 0 0))
#f
(pict-last p)))
It seems to me that it would have been better to have separate smoothing settings for bitmaps and path drawings.
(scale (unsmoothed (bitmap (copy-bitmap-section bm 0 0 50 50))) 8)
Thanks. That’s near what I was thinking.
@samdphillips Do you see the blurring if you wrap the bitmap pict with size-in-pixels
before scaling?
I’ll give that a try.
@ryanc still blurry that way and squished a bit
@soegaard2 unsmoothed
works
@dotsond96 has joined the channel
What is the reason for doing the copy in a dc
pict and then copying it to the one that is returned?
@joel has joined the channel
Good question. It’s to preserve the ascent and descent.
Also p2 does not have the correct pict-last value.