I want to format some trees into png files. This code from StackOverflow makes a great diagram in the interactive window. When I follow the suggestion in the comment to save to a file, the png ends up with a solid black background. Can someone help with changing the saved png to a white background?
It is likely that the PNG has a transparent background, as this is the default, and the tool you use to view the PNG uses black as the background.
My own preferred way to solve this problem is to add an explicit rectangle to the pict, which acts as the background -- you can control the color. However, the pict->bitmap function has a #:make-bitmap parameter and you can pass a lambda to create a bitmap without an alpha channel.
Edit: I suppose , I should provide an example
(define generated-pict (draw t1))
(define bg
(filled-rectangle (pict-width generated-pict) (pict-height generated-pict)
#:color "yellow"
#:draw-border? #f))
;; Save this one to PNG
(define pict-with-background (cc-superimpose bg generated-pict))