Reputation: 337
I've been trying to make a user application for drawing tileset bitmaps, so something a bit like this (multiple layers of fg color/alpha, bg color/alpha, and characters):
Creating the bitmap isn't a problem, but now I'm at the part where I'd like to edit and make modifications to it. I'm satisifed with the bitmap output but I notice if I've already printed a bitmap once I can no longer make changes to it
I've already checked the documentation for bitmap%, bitmap-dc%, and dc% but I couldn't find any information if this is intentional. Am I missing a step inbetween?
Update: I notice that if I copy the bitmap to another bitmap after drawing than the changes will visible in the new bitmap but the old one doesn't
Here is the sample code
#lang racket
(require racket/draw)
(define bmp1 (make-bitmap 128 128))
(define bdc1 (new bitmap-dc% [bitmap bmp1]))
(send bdc1 set-pen "yellow" 1 'solid)
(send bdc1 set-brush "black" 'solid)
(send bdc1 draw-rectangle 0 0 128 128)
(send bdc1 draw-rectangle 0 0 64 64)
(send bdc1 draw-line 0 0 128 128)
bmp1
(send bdc1 set-pen "red" 4 'solid)
(send bdc1 draw-line 128 0 0 128)
bmp1
(define bmp2 (make-bitmap 128 128))
(define bdc2 (new bitmap-dc% [bitmap bmp2]))
(define d (send bdc2 draw-bitmap bmp1 0 0))
bmp2
bmp1
Upvotes: 4
Views: 306
Reputation: 31145
I am 90% sure that you are seeing the results of a bug in DrRacket. And I am almost sure that the bug has been fixed already.
https://www.cs.utah.edu/plt/snapshots/
Can I talk you into installing the development version from the above link?
The bug in question: https://github.com/racket/drracket/commit/2d3205571cb4d1d38335c4bac84810e72777c769
Upvotes: 1