[plt-scheme] The transparent color?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Dec 3 18:26:11 EST 2002

At Thu, 28 Nov 2002 17:45:12 -0500, "Ghis Lafortune" wrote:
> I'm a student of Sherbrook's University and I'm programming a chess game. I've 
> encounter a problem with the pieces. I've put a transparent background but 
> Drscheme show it white. 
> I'm using a viewport and all my pics are in gif format. 
> How do I say to Drscheme to know that the "white" background is transparent? 

Short answer:

The viewport graphics library doesn't currently draw bitmaps with
transparency. I've fixed that for the next release.


Slightly longer answer:

By using the underlying MrEd toolbox, It's almost possible to draw GIFs
with transparent backgrounds. There is a bug, however, in the v202
distribution.

(Also, the `viewport-dc' and `viewport-buffer-dc' functions, which
provide a bridge to the underlying toolbox, seem to be undocumented.
I've fixed that for the next release, too.)


Long answer:

In version 202, you can use the type 'gif/mask (or 'unknown/mask) when
loading a bitmap from a file. If the file contains a GIF with a
transparent index, the resulting bitmap will contain a mask bitmap,
which you can access through the `get-loaded-mask' method. Finally, use
the mask bitmap as the last argument to dc<%>'s `draw-bitmap' when
drawing the loaded bitmap. (In future versions, maybe the mask bitmap
stored with the main bitmap will be used automatically.)

At least, that's the theory. But the `get-loaded-mask' method was
missing in the v202 distribution. You can correct the bug by editing
   plt/collects/mred/private/kernel.ss
Find the definition of bitmap%, and add `get-loaded-mask' to its list
of methods.


Matthew



Posted on the users mailing list.