thank you so much!<div>it works very well~!</div><div>and I realize that the png files what I used is does not have any transparency </div><div>could you let me know how to set a color as transparent as well?<br><div><br><div class="gmail_quote">
On 21 November 2010 23:08, Matthew Flatt <span dir="ltr"><<a href="mailto:mflatt@cs.utah.edu">mflatt@cs.utah.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">At Sun, 21 Nov 2010 10:55:22 +0900, 김태윤 wrote:<br>
> it's about 10 hours since I stuck at overlaying several images<br>
> (make only selected color to transparent)<br>
> could somebody give me an little advice?<br>
> just little hint about big picture would be very helpful for me.<br>
> please~~!<br>
><br>
> #lang racket/gui<br>
> (define base-dc (make-object bitmap-dc% (make-object bitmap% 320 320 #f) ))<br>
> (define m-canvas%<br>
> (class canvas%<br>
> (override on-paint)<br>
> (define on-paint (λ () (send (send this get-dc) draw-bitmap (send<br>
> base-dc get-bitmap) 0 0)))<br>
> (super-new)))<br>
> (define color (make-object color% "red"))<br>
> (define f (new frame% (label "a")))<br>
> (define c (new m-canvas% (parent f)(min-width 320) (min-height 320)))<br>
> (send base-dc draw-bitmap (make-object bitmap% "./src/arena.png") 0 0 )<br>
> (send base-dc set-argb-pixels 0 0 288 256 (make-bytes (* 4 288 256)))<br>
> (send base-dc draw-bitmap (make-object bitmap% "./src/char4.png") 0 0 )<br>
> (send f show #t)<br>
<br>
</div></div>Is the problem that "arena.png" and "char4.png" are images with<br>
transparency, but `draw-bitmap' draws them solid?<br>
<br>
If so, you need to supply 'png/mask as the after the pathname when<br>
loading the bitmap<br>
<br>
(define bm1 (make-object bitmap% "./src/arena.png" 'png/mask))<br>
<br>
and then use the bitmap mask when drawing:<br>
<br>
(send base-dc draw-bitmap bm1<br>
0 0 solid<br>
(send the-color-database find-color "black")<br>
(send bm1 get-loaded-mask))<br>
<br>
<br>
It's much simpler in the current development version of Racket, where<br>
transparency is more directly supported on bitmaps. In version<br>
5.0.99.2,<br>
<br>
(send base-dc draw-bitmap (read-bitmap "./src/arena.png") 0 0)<br>
<br>
automatically loads and uses transparency information.<br>
<br>
</blockquote></div><br></div></div>