<div>Problem: The dc% method &#39;draw-bitmap-section disregards the boundaries of the drawing section when the &#39;color argument is the color black.</div><div><br></div><div>Not only does the documentation clearly state that the &#39;color argument should be ignored for a color bitmap, but it&#39;s quite bizarre that, upon seeing black, it decides to draw the whole bitmap, whereas if black is replaced by (say) green, it correctly draws only the specified section. I have observed this on nightly builds from the last several days on both Mac OS X and Linux.</div>

<div><br></div><div>For convenience, I have attached one of the bitmaps and masks I&#39;ve used.</div><div><br></div><div>Next, I complain about some other weird behavior of bitmaps (this behavior has, I think, existed for a long time). In the following example (code at the bottom of this email), I load a black-and-white bitmap (which seems to load as color), then create two bitmaps inside bitmap-dc%s (one monochrome and the other color), draw the original black-and-white bitmap to each of these bitmap-dc%s, and extract the bitmaps from the bitmap-dc%s. Now I have three black-and-white bitmaps that all look identical: the originally loaded one, the monochrome copy, and the color copy.</div>
<div><br></div><div>Now I try to use them as masks to draw the &quot;valkyrie&quot; bitmaps. What happens? The first one works, the second and third don&#39;t. Why is this? I investigated and found that, while the pixels of the copies are identical to those of the original (at least, the color copy is identical to the original), the &quot;alpha&quot; channel is different: the alpha bytes are all 0 on the original, but they&#39;re all 255 on both of the copies.</div>
<div><br></div><div>Questions/complaints:</div><div>1. Why does the alpha channel of a bitmap matter when it&#39;s being used as a mask?</div><div>2. Why doesn&#39;t drawing a bitmap to another one of the same size produce an exact copy of the first? (Or, if, say, the second one is monochrome while the first is color, why doesn&#39;t it produce the monochrome equivalent of the first? And vice versa.)</div>
<div><br></div><div>Code for REPL (the PNGs are needed again):</div><div><br></div><div>;Constructs three black-and-white bitmaps as described above.</div><div>;For each, draws the bitmap, then draws the &quot;valkyrie&quot; thing using the bitmap</div>
<div>; as a mask, then prints out whether it&#39;s color and the value of the 0th alpha byte.</div><div><div><div>(let* ((u (make-object bitmap% &quot;valkyrie.png&quot;))</div><div> (um (make-object bitmap% &quot;valkyrie-umask.png&quot;))</div>
<div> (umm (make-object bitmap-dc%</div><div> (make-monochrome-bitmap (send um get-width) (send um get-height))))</div><div> (umc (make-object bitmap-dc%</div><div> (make-bitmap (send um get-width) (send um get-height)))))</div>
<div> (send umm draw-bitmap um 0 0)</div><div> (send umc draw-bitmap um 0 0)</div><div> (let ((mu (send umm get-bitmap))</div><div> (cu (send umc get-bitmap)))</div><div> (for-each (lambda (x)</div><div> (send dc clear)</div>
<div> (send dc draw-bitmap x 0 0)</div><div> (sleep 1)</div><div> (send dc clear)</div><div> (send dc draw-bitmap u 0 0 &#39;solid (make-object color% &quot;green&quot;)</div>
<div> x)</div><div> (for-each display (list &quot;color? &quot; (send x is-color?)</div><div> &quot; alpha-byte &quot; (let ((c (make-bytes 9000)))</div>
<div> (send x get-argb-pixels 0 0 10 10 c &#39;t)</div><div> (bytes-ref c 0))))</div><div> (newline)</div>
<div> (sleep 1))</div><div> (list um mu cu))))</div></div></div>--John Boyle<br>