Working with Alpha Channels


Image-editing programs such as Photoshop and Fireworks allow you to create an image against a "transparent" background ( Figure 8.33 ). In reality, there's no such thing as a transparent backgroundthe pixels in a bitmapped image are always opaque . What these programs really do is create a mask at the same time you create your image, and then use this mask to give the illusion of transparency when the image is displayed on your screen ( Figure 8.34 ).

Figure 8.33. Here, this image of a smokestack appears on what looks like a transparent background in Photoshop.


Figure 8.34. But behind this smokestack, a hidden Photoshop mask helps create the illusion of transparency.


When you save the file in the program's native file format (for example, a PSD file in Photoshop or a PNG file in Fireworks), the mask is saved with the file in the form of an alpha channel. In essence, an alpha channel functions much like an ink mask in Director, except that its contents are stored as part of the image file.

You can import images with alpha channels into Director. When you do so, Director automatically recognizes the alpha channel and uses it to provide transparency.

Cast members with alpha channels are extremely well suited for compositing in Director. Because the mask in the alpha channel was created at the same time as the image, it's flawless and seamless. It allows anti-aliased edges to blend perfectly into any background.

The drawback of images with alpha channels is that they use a lot of disk space and require extra processing power. To store an alpha channel with an image, you must save the image as a 32-bit file, which means that 32 bits of information are used to describe each pixel in the image. When Director animates the image, it must process all 32 bits of information for each pixel over and over again, frame by frame. This can put a heavy load on the computer's processor and slow down the movie.

If the file size or processor load of a 32-bit file is a problem for your movie, you can open the image in an external image-editing program and save it as two separate files: one 8-bit file for the image and another for the mask (See the sidebar, "A Quick Detour into Photoshop," later in this chapter) You can then import both files into Director and use them as described in "To use an imported ink mask," earlier in this chapter.

To use an image that has an alpha channel:

  1. Import the image file into Director.

    When the Image Options dialog box appears, be sure to set the color depth to 32 bits. If you specify a lower color depth, you'll lose the alpha channel ( Figure 8.35 ).

    Figure 8.35. When you import a file that has an alpha channel, be sure to import it as a 32-bit image.


  2. Drag the image from the Cast window to the Stage or Score.

    Director automatically recognizes the alpha channel and uses it to provide transparency ( Figure 8.36 ).

    Figure 8.36. Director uses the alpha channel to composite the image.


graphics/tick.gif Tips

  • A sprite with an alpha channel will look exactly the same on the Stage regardless of whether its ink effect is set to Copy, Background Transparent, or Matte.

  • Occasionally, Director will have trouble importing a native Photoshop (PSD) file. If this happens, go back into Photoshop and save the image as a PICT or TIFF file, following the directions in the sidebar "A Quick Detour into Photoshop."

  • If you want Director to disregard a cast member's alpha channel, go to the Property Inspector's Bitmap tab and deselect Use Alpha ( Figure 8.37 ).

    Figure 8.37. The Use Alpha option is selected by default, but you can deselect it if you want Director to ignore a cast member's alpha channel.


To edit a cast member that has an alpha channel:

  • Edit the image in Director's Paint window.

    The Paint window doesn't recognize or let you edit alpha channels, so it will leave existing alpha channels intact ( Figure 8.38 ).

    Figure 8.38. When you edit a cast member in the Paint window, its alpha channel is unaffected. As a result, even if you edit it sloppily (left), the out-of-bounds brushstrokes are masked out by the alpha channel on the Stage (right).



    Edit the image in an external program such as Photoshop or Fireworks if you do want to modify the alpha channel along with the image.

graphics/tick.gif Tips

  • If you want to edit a cast member in Fireworks, right-click (Windows) or Control+click (Mac) the cast member in the Cast window and choose Launch External Editor from the contextual menu ( Figure 8.39 ). If Fireworks is installed on your computer, Director will automatically launch it and open the selected cast member for editing.

    Figure 8.39. Choose Launch External Editor from a cast member's contextual menu to launch Fireworks (the default) or whatever image-editing program you prefer.


  • If you want to edit a cast member in Photoshopor in any image-editing program other than the default Fireworkschoose Edit > Preferences > Editors (Windows) or Director > Preferences > Editors (Mac) and specify the program you want to use to edit each file type ( Figure 8.40 ). Thereafter, when you choose Launch External Editor from a cast member's contextual menu, the specified program will be launched.

    Figure 8.40. In the Editors Preferences dialog box, you can specify which program will be launched by the Launch External Editor command when you edit a particular cast member.


A Quick Detour into Photoshop

OK, we know this is a Director book, not a Photoshop book. But since most Director users do their image editing in Photoshop, you'll probably find this information useful.

When you create an image, Photoshop stores the transparency information for each layer in a hidden channel called the transparency channel . If you want to save this transparency information in a file format other than Photoshop's native PSD, or if you want to export a separate mask file, you have to convert the various layers ' transparency channels into one standard alpha channel. Here's an easy way to do it:

  1. If your image has any alpha channelsthat is, if there's anything on the Channels palette other than RGB, Red, Green, and Blueselect those extra channels on the Channels palette and delete them.

  2. If your image has a Background layer, double-click it in the Layers palette.

    The New Layer dialog box appears, with Layer 0 displayed as the layer name .

  3. Click OK.

    The Background layer is converted to a normal layer.

  4. If your image has more than one layer, choose Layer > Merge Visible to merge them into a single layer with a single transparency channel.

  5. Choose Select > Load Selection.

    The Load Selection dialog box appears ( Figure 8.41 ). Make sure Layer X Transparency (where X represents the name of your layer) is displayed on the Channel pop-up menu, and the New Selection radio button is selected under Operation.

    Figure 8.41. The Load Selection dialog box in Photoshop.


  6. Click OK.

    The transparent and semi-transparent areas of your image are selected on the screen.

  7. Choose Select > Save Selection.

    The Save Selection dialog box appears ( Figure 8.42 ). Make sure New is displayed on the Channel pop-up menu, and New Channel is selected under Operation.

    Figure 8.42. Click Save in the Save Selection dialog box.


  8. Click OK.

    The transparency information is converted to an alpha channel called Alpha1.

    Now, if you save the image as a PICT (Macintosh only) or TIFF file, the alpha channel will be saved with the image.

    If you want to save the transparency information as a separate mask file rather than as an alpha channel, you can choose Split Channels from the Options menu on the Channel palette. (Make sure you've saved your image before you do this, because the Split Channels command is not reversible.) You can then select the image window containing the alpha channel and save it separately.


Macromedia Director MX for Windows and Macintosh. Visual QuickStart Guide
Macromedia Director MX for Windows and Macintosh. Visual QuickStart Guide
ISBN: 1847193439
Year: 2003
Pages: 139 © 2008-2017.
If you may any questions please contact us: