O'Reilly logo

REALBasic: TDG, 2nd Edition by Matt Neuburg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Transparency and Icons

An image is transparent if some of its pixels are not drawn, or are not fully drawn; whatever is behind the image is visible wherever the image has transparent pixels. An image can be made transparent in three ways:

  • Through a Picture’s Transparent property

  • Through a Picture’s Mask property

  • Through the mask information accompanying an icon

These will now be treated in turn.

Transparent Property

Using a Picture’s Transparent property, only the color white, rgb(255,255,255), can be rendered transparent. If you want to turn some other color of an image transparent, go through all its pixels, turning each white one to some other color (which may be fairly close to white, so that it looks white to the user), and then go through them again, turning white all pixels that you wish to be transparent. The rule is that if a Picture’s Transparent property is 1, white pixels are not copied from it when it is copied with DrawPicture into a Graphics property. A Canvas’s Graphics property, you remember, is itself transparent: any undrawn pixels are invisible. A Canvas’s Backdrop property, on the other hand, is transparent only if the Picture instance to which it points has its Transparent property set to 1.

For example, suppose our project has incorporated into it a Resource file containing a 'PICT' resource with ID 1000 which we wish to display transparently in a window. We create a Picture property, GWorld, to hold the picture in its transparent form.[100] In the Open event handler ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required