Programming for Transparency
To support transparency in bitmaps, the Bitmap and Form_Bitmap properties support two optional flags at the end of the bitmap name:
Flags
| Flag | Description |
|---|---|
/t |
Will change all white pixels in your bitmap to the "Window" color of the machine displaying the image. Technically, the clWhite color will be changed to clWindow. |
/3d |
Will convert the following colors: |
Color Conversion
| Color | To Color |
|---|---|
| Lt Gray (RGB: 223,223,223) | clBtnHighlight |
| Gray (RGB: 192,192,192) | clBtnFace |
| Dark Gray (RGB: 128,128,128) | clBtnShadow |
The purpose of this option is to permit bitmaps that use "standard" 3D colors to look like 3D objects on the target machine.
Note
You can use /t and /3d together. The result is that /t will take precedence, but white pixels will be changed to the 3D object color. Technically, clWhite will be changed to clBtnFace.
Examples
If you have bitmaps that use gray backgrounds, this is how you would change your code from:
Set Bitmap To "AbUp.bmp"
to:
Set Bitmap To "AbUp.bmp/3d"
If you have a bitmap with a white background, to display it on a Textbox, you would write:
Object oTextbox is a Textbox
Set Color To clWindow
Set Bitmap To "HappyFace.bmp/t"
End_Object
And, to display it on a Button, you would write:
Object oButton is a Button
Set Bitmap To "HappyFace.bmp/t/3d"
End_Object
Limitations
A current limitation of Windows transparency is that bitmaps can only be 256 or fewer colors. Therefore, you may need to reduce the number of colors in your bitmaps if you want to display them transparently.
Related Topics
- Image Support explains the enhancements that have been made to support images.
- Embedded Resources explains what resources are and their advantages.
- The Application Properties dialog in the Studio is used to maintain the list of resources that should be linked into your programs.