[racket] make only selected color to transparent

From: 김태윤 (kty1104 at gmail.com)
Date: Sun Nov 21 09:34:26 EST 2010

thank you so much!
it works very well~!
and I realize that the png files what I used is does not have any
transparency
could you let me know how to set a color as transparent as well?

On 21 November 2010 23:08, Matthew Flatt <mflatt at cs.utah.edu> wrote:

> At Sun, 21 Nov 2010 10:55:22 +0900, 김태윤 wrote:
> > it's about 10 hours since I stuck at overlaying several images
> > (make only selected color to transparent)
> > could somebody give me an little advice?
> > just little hint about big picture would be very helpful for me.
> > please~~!
> >
> > #lang racket/gui
> > (define base-dc (make-object bitmap-dc% (make-object bitmap% 320 320 #f)
> ))
> > (define m-canvas%
> >   (class canvas%
> >     (override on-paint)
> >     (define on-paint (λ () (send (send this get-dc) draw-bitmap (send
> > base-dc get-bitmap) 0 0)))
> >     (super-new)))
> > (define color (make-object color% "red"))
> > (define f (new frame% (label "a")))
> > (define c (new m-canvas% (parent f)(min-width 320) (min-height 320)))
> > (send base-dc draw-bitmap (make-object bitmap% "./src/arena.png") 0 0 )
> > (send base-dc set-argb-pixels 0 0 288 256 (make-bytes (* 4 288 256)))
> > (send base-dc draw-bitmap (make-object bitmap% "./src/char4.png") 0 0 )
> > (send f show #t)
>
> Is the problem that "arena.png" and "char4.png" are images with
> transparency, but `draw-bitmap' draws them solid?
>
> If so, you need to supply 'png/mask as the after the pathname when
> loading the bitmap
>
>   (define bm1 (make-object bitmap% "./src/arena.png" 'png/mask))
>
> and then use the bitmap mask when drawing:
>
>   (send base-dc draw-bitmap bm1
>                 0 0 solid
>                 (send the-color-database find-color "black")
>                 (send bm1 get-loaded-mask))
>
>
> It's much simpler in the current development version of Racket, where
> transparency is more directly supported on bitmaps. In version
> 5.0.99.2,
>
>  (send base-dc draw-bitmap (read-bitmap "./src/arena.png") 0 0)
>
> automatically loads and uses transparency information.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20101121/ffe96236/attachment.html>

Posted on the users mailing list.