support svg-bytes for 2htdp/image images
This commit is contained in:
parent
5508e4fc58
commit
6e062466a0
|
@ -238,6 +238,7 @@ has been moved out).
|
|||
(let ([s (open-output-bytes)])
|
||||
(send (to-bitmap (to-img img)) save-file s 'png)
|
||||
(get-output-bytes s))]
|
||||
[(svg-bytes) (to-svg-bytes img)]
|
||||
[else default]))]
|
||||
[prop:pict-convertible
|
||||
(λ (image)
|
||||
|
@ -267,6 +268,19 @@ has been moved out).
|
|||
(send bdc set-bitmap #f)
|
||||
bm)
|
||||
|
||||
(define (to-svg-bytes img)
|
||||
(define bb (send img get-bb))
|
||||
(define w (min (inexact->exact (ceiling (bb-right bb))) maximum-width))
|
||||
(define h (min (inexact->exact (ceiling (bb-bottom bb))) maximum-height))
|
||||
(define s (open-output-bytes))
|
||||
(define svg-dc (new svg-dc% [width w] [height h] [output s]))
|
||||
(send svg-dc start-doc "")
|
||||
(send svg-dc start-page)
|
||||
(render-image img svg-dc 0 0)
|
||||
(send svg-dc end-page)
|
||||
(send svg-dc end-doc)
|
||||
(get-output-bytes s))
|
||||
|
||||
(define-local-member-name
|
||||
set-use-bitmap-cache?!
|
||||
set-cached-bitmap
|
||||
|
|
Loading…
Reference in New Issue
Block a user