Home > Articles > Graphics & Web Design > Dreamweaver & Flash

  • Print
  • + Share This
This chapter is from the book

Using Bitmaps (Also Known as Raster Graphics)

In this section, you see how bitmap (raster) graphics can be used in Flash. Raster graphics have inherently unique characteristics that can't be created inside Flash. The only warning related to using this option is to make sure you really need raster graphics. The following are some cases that justify the use of raster graphics:

  • A photograph—The only time to consider using a vector alternative to a photograph is when the picture is of a geometric object. Otherwise, photographs should be raster graphics.
  • A series of still images—These may be extracted from frames of a short video.
  • An image with special effects that can't be achieved with a vector tool—Examples include clouds, fire, water, and other natural effects. Of course, this is a challenge for a talented artist to re-create such an effect by using a vector tool such as Flash.

If you're unfamiliar with the difference between vector graphics and raster graphics, learning when one choice is better than the other can take some time. The file formats .gif, .jpg, .png, .bmp, and .pct are all raster graphics formats. However, because a file was saved in one of these formats doesn't mean it was automatically the best possible choice. It's the nature of the image in the file that matters. If all you have is a .gif, for example, you need to first look at its contents to judge whether it's appropriate as a raster graphic. An easy way to decide is if you can trace or redraw the image in the file (for instance, with Flash's drawing toolbar) you're much better off redrawing it. If it's a photograph, you would never be able to re-create it with vector graphic drawing tools, so leave it as a raster graphic. If it's a picture of a plain box, maybe you could draw it and thus take advantage of raster graphics.

To make matters slightly more complex, you can use Photoshop to create and edit layered bitmapped images. When importing Photoshop documents, you can decide exactly how to import each individual layer. In addition, Photoshop supports editable text, which isn't a raster graphic. Because importing Photoshop files is more involved, a separate section, "Importing Layered Raster Graphics," that discusses importing such layered documents following the more general discussion of importing flat raster graphics.

Importing Flat Raster Graphics

Importing a flat raster graphic (that is, not a Photoshop file), is pretty simple to do. You click File, Import, and Import to Stage, to open the Import dialog box, and then point to any raster graphic that Flash supports, such as .jpg, .png, .gif, .bmp, .tif, or .pct. That's it.

Importing not only places the graphic on the Stage, but also puts a master bitmap item into the Library. If you import a raster graphic and then delete the object from the Stage, the master bitmap item is still in the Library panel, which you can open by selecting Window, Library. It's called a Bitmap Item, and it has a little icon that looks like a picture of a tree (as shown in Figure 3.5).

Figure 3.5

Figure 3.5 After you import a raster graphic, the Bitmap Item appears in your Library panel.

After a raster graphic is imported, you need to keep it in the Library. The Bitmap Item icon that appears in the Library provides a way to specify how the image should be exported when you create a movie for the web. If you leave it unchanged, your raster graphics export under the default settings. You can also specify special settings for just that image. In the following task, you import a raster graphic and explore some of these settings.

Adjusting Bitmap Properties

Flash imports all kinds of raster formats, but uses only JPEG, GIF, or PNG in an exported movie. In addition, any raster graphic is generically called a bitmap item after it's inside Flash's Library. No matter what file type you import, you must use the Bitmap Properties dialog box to choose between JPEG (and its compression level) and lossless GIF/PNG for exporting. If you decide to use JPEG compression, you want to experiment with different settings and click the Test button after each change to see the effects on both image quality (in the little picture at the top left) and file size (in the text information at the bottom of the dialog box), as shown in Figure 3.7). The process involves experimentation—making adjustments and viewing the corresponding results.

Figure 3.7

Figure 3.7 Selecting a low JPEG compression (10) and clicking Test provides a preview of the resulting image and its file size.

JPEG compression is usually the most efficient option. Unless you import a .png or .gif, Flash sets the bitmap properties to JPEG by default. It's slightly confusing because if you import a .jpg file, Flash uses Imported JPEG Data by default, as shown in Figure 3.8. This option tells Flash to maintain the imported file's original compression (that is, don't recompress). Leaving this option selected is generally desirable because it's a bad idea to recompress.

Figure 3.8

Figure 3.8 Only imported .jpg files enable you to use the JPEG compression contained in the original file.

Importing other popular formats, such as .bmp and .pct, also causes Flash to opt for JPEG compression by default. And even though you are using a Bitmap file type and not JPEG, as shown in Figure 3.9, the options remain the same.

Figure 3.9

Figure 3.9 When you import non-.jpg files, you can still use JPEG compression settings.

You can control what compression method is used on individual imported images by deselecting Use Document Default Quality or deselecting Use Imported JPEG Data, but keep in mind the earlier caution about recompression. When this option is deselected, a field appears where you can type the JPEG compression level you desire. Instead of guessing what compression level is best, you can use the Bitmap Properties dialog box to experiment. A lower number results in a smaller file but also lowers the quality. If you click Test after each change, you see a drastic difference between 100 and 1. After you make each change, you can click the Test button to review the effect on file size and quality, as shown in Figure 3.10. You should experiment until you get the best compromise of image quality and file size.

Figure 3.10

Figure 3.10 Setting the quality to 5 cuts this image size to less than 1/100 of its original, but the quality is visibly affected.

The image portion shown in the image window at the top left of the Bitmap Properties dialog box shows exactly how the image looks when it is exported. You can zoom into this window by right-clicking, and then you can pan around to get a better view.

If you plan on compressing an image inside Flash, you might want to use PNG. This file type compresses better than JPEG and results in a better quality final image.

Figure 3.11 shows the results of using several different compression levels on the same image. Notice JPEG 80 and JPEG 100 are almost identical in quality, but JPEG 80 has a much smaller file size.

Figure 3.11

Figure 3.11 The results of different compression settings on the same image shows how quality degrades and file size shrinks.

You get the ultimate quality by using the compression option Lossless (GIF/PNG). It is selected by default when you import .png and .gif files, but you can select it any other time you want to use it. When this option is selected, Flash leaves the image in its original state. This option always provides the best quality—but not without a price. File size is highest when this option is selected. This is a suitable alternative if you're making a movie that doesn't need to download from the web—for example, if you're making a presentation that you are delivering on your hard drive or CD-ROM. Otherwise, you should use this option only on images where you want to retain the best quality possible. If your imported image is a .gif that already has a small file size, selecting Lossless is perfectly suitable. Because even 100% JPEG compression causes some image degradation, the Lossless option is suitable for images that are particularly important. Finally, the only way Flash supports 32-bit graphics (that is, raster images with varying degrees of transparency) is through .png items that you set to Lossless. The fact that PNG is the only format that supports transparency is another perfectly legitimate reason to use PNG.


Regardless of which compression option you use for your imported bitmaps, Allow Smoothing (as shown earlier in Figure 3.10) is another option in the Bitmap Properties dialog. If you plan to scale or rotate the raster graphic, you want to click that check mark. Normally, a bitmap with its explicit number of pixels looks fine without smoothing. However, smoothing lets Flash apply a tiny bit of blur when the image's pixels don't align perfectly with the screen's pixels, which is the case when you rotate or scale an image. You can see the effect of smoothing in a side-by-side comparison in Figure 3.12.

Figure 3.12

Figure 3.12 Applying smoothing to the image on the left improves it when rotated, but the same effect makes the image look soft.

The downside of smoothing is images can look a bit fuzzy, so don't use it if you're not rotating or scaling the image. If you're using the image in a detailed animation, you want to opt for smoothing. Compared to how raspy a modified image looks without smoothing, you probably want to click the check mark to enable smoothing when appropriate.

Importing Layered Raster Graphics

Flash CS4 can import Photoshop .psd files. The value is that artists can work in Photoshop, and you can conveniently import the graphics they create. Compared to having the artist individually export each element and then you import it and place it in the correct position, this is a huge workflow improvement. What's doubly great about this new feature is that it's so intuitive there's not a whole lot to learn.

Like the Illustrator Import dialog, when you select File, Import, Import to Stage and point to a Photoshop file, you see all the layers and folders contained in the source Photoshop file, as shown in Figure 3.13.

Figure 3.13

Figure 3.13 Importing a Photoshop document allows you to select how to import each layer.

There are some striking similarities between the Photoshop import dialog and the Illustrator one discussed earlier—though this one is more advanced. You can see similar global options at the bottom left as to whether to keep objects in position and or to convert layers into Flash layers or keyframes. Also similar is the way you can include or exclude layers by clicking check marks.

A particularly handy feature in Photoshop, called layer comps, lets you save multiple arrangements of your layers and their contents. Artists can include tons of layers with all the graphics for an entire project in a single Photoshop file. Then, they can make multiple compositions—for example, one where only the layers related to the home screen in your project are visible and another where the layers for a video section are visible. With layer comps, artists can quickly view different arrangements without going through and turning layers on and off. When you import a Photoshop document with layer comps, you see them listed at the top left, as shown in Figure 3.14. This gives you a quick way to select all the layers related to a particular layout.

Figure 3.14

Figure 3.14 You can use the Layer Comp drop-down to quickly select the layers related to a particular layout.

After you've selected the layers you want to import, you can set the options for how each layer gets imported on the right side of the import dialog. Provided you don't want to accept the defaults, you individually select each layer and make adjustments to the options on the right. All layer types can be imported as a flattened bitmap, which is the best way to retain the exact look created by the artist. You see slightly different options in text layers and shape layers, but the big difference from the Illustrator importer discussed earlier is that for each layer you import as a flattened bitmap, you can individually set the publish settings.

The publish settings for each imported layer affect the Bitmap properties for the contained objects when they appear in the Library. These settings are the same ones you learned about in the previous section "Adjusting Bitmap Properties." This way, you can make the decision between JPEG and PNG/GIF and whether to use Flash document's publish settings for compression or set them individually for each item. The odd thing is that the terms are slightly different than the ones you just learned. Where the Photoshop importer says Lossy Compression, it means JPEG in the Bitmap Properties dialog (accessible by double-clicking an item after it's in the Library). Where the Photoshop importer says Lossless, it means PNG.

Although you always see the best quality by importing layers as flattened bitmaps, other options also have some value. In the case of text layers, you can opt to import as editable text. You can make edits to the actual wording later, but realize you immediately lose any layer effects applied to the text. Photoshop supports very detailed text effects that are unmatched in Flash.

For both shape and text layers, you can choose to keep paths and layer styles editable. Not only does this mean you see subtle differences in the image after it's inside Flash, but a complex Photoshop document translates to a complex Flash document. Be prepared to test any import process if you're not importing as flattened bitmaps.

To summarize the suggested workflow, select the layers you want to import, either by clicking the check marks or by selecting a layer comp, which effectively selects the layers for you. Then, go through each layer to adjust the publish settings or do this later via the Library item's bitmap properties.

  • + Share This
  • 🔖 Save To Your Account