From 9476c57ead3f5bb9649d7e8a019a21fb6a7de839 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Sun, 10 Jan 2010 13:55:11 +0000 Subject: [PATCH] fixed image equality for zero width & zero height images svn: r17593 original commit: 708d4c10d6cc306737184c425fc6129fc20bfa59 --- collects/mrlib/image-core.ss | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/collects/mrlib/image-core.ss b/collects/mrlib/image-core.ss index 8ab224a4..829dab35 100644 --- a/collects/mrlib/image-core.ss +++ b/collects/mrlib/image-core.ss @@ -206,15 +206,17 @@ has been moved out). (equal? (get-normalized-shape) (send that get-normalized-shape))) (and (is-a? that image%) (same-bb? bb (send that get-bb)) - (let* ([w (round (inexact->exact (bb-right bb)))] - [h (round (inexact->exact (bb-bottom bb)))] - [bm1 (make-object bitmap% w h)] - [bm2 (make-object bitmap% w h)] - [bytes1 (make-bytes (* w h 4) 0)] - [bytes2 (make-bytes (* w h 4) 0)] - [bdc (make-object bitmap-dc%)]) - (and (check-same? bm1 bm2 bytes1 bytes2 bdc "red" that) - (check-same? bm1 bm2 bytes1 bytes2 bdc "green" that)))))) + (let ([w (round (inexact->exact (bb-right bb)))] + [h (round (inexact->exact (bb-bottom bb)))]) + (or (zero? w) + (zero? h) + (let ([bm1 (make-object bitmap% w h)] + [bm2 (make-object bitmap% w h)] + [bytes1 (make-bytes (* w h 4) 0)] + [bytes2 (make-bytes (* w h 4) 0)] + [bdc (make-object bitmap-dc%)]) + (and (check-same? bm1 bm2 bytes1 bytes2 bdc "red" that) + (check-same? bm1 bm2 bytes1 bytes2 bdc "green" that)))))))) (define/private (check-same? bm1 bm2 bytes1 bytes2 bdc color that) (clear-bitmap/draw/bytes bm1 bdc bytes1 this color) @@ -523,18 +525,20 @@ has been moved out). [brush (send dc get-brush)] [font (send dc get-font)] [fg (send dc get-text-foreground)]) - (let loop ([shape (send image get-normalized-shape)]) - (cond - [(overlay? shape) - (render-cropped-simple-shape (overlay-bottom shape) dc dx dy) - (loop (overlay-top shape))] - [else - (render-cropped-simple-shape shape dc dx dy)])) + (render-normalized-shape (send image get-normalized-shape) dc dx dy) (send dc set-pen pen) (send dc set-brush brush) (send dc set-font font) (send dc set-text-foreground fg))) +(define (render-normalized-shape shape dc dx dy) + (cond + [(overlay? shape) + (render-cropped-simple-shape (overlay-bottom shape) dc dx dy) + (render-normalized-shape (overlay-top shape) dc dx dy)] + [else + (render-cropped-simple-shape shape dc dx dy)])) + (define (render-cropped-simple-shape shape dc dx dy) (cond [(crop? shape)