Bitmaps Contents........................................................................................................ 1
Bitmaps........................................................................................................................... 1
DefineBits...................................................................................................................... 1
DefineBitsJPEG2............................................................................................................. 2
DefineBitsJPEG3............................................................................................................. 2
DefineBitsLossless.......................................................................................................... 2
DefineBitsLossless2......................................................................................................... 3
JPEGTables.................................................................................................................... 4
SDK Examples................................................................................................................. 4
SWF supports a variety of bitmap formats. One JPEG format has a JPEG header that is shared between multiple JPEG images in a single SWF file to minimize file size. Another JPEG format lets each image have it's own header, allowing each image its own compression settings. The zlib format is similar to an embedded PNG file and is used when you need lossless image compression. This is best for images that would compress well as a GIF file like screen shots or diagrams, while JPEG is best for photographs.
Bitmaps in SWF can also contain alpha channel information. For lossless compression, there can be alpha channel information in a color table of an 8-bit image or there can be full alpha channel information for a 32-bit image. For JPEG images, alpha channels are stored using lossless zlib compression.
Note that when a bitmap in a SWF file is rendered, the full transform operation is applied to the image including the matrix transformation and the color transform operation.
Defines a bitmap character with JPEG compression. This tag contains only the JPEG compressed image data (as defined by the Independent JPEG Group). JPEGTables contains the JPEG encoding data used to encode this image. (SWF 1.0)
(See class FDTDefineBits in the Flash File Format SDK)
DefineBits |
||
Field |
Type |
Comment |
Header |
RECORDHEADER |
Tag ID = 6 |
BitmapId |
UI16 |
ID for this character |
BitmapJPEGImage |
UI8[image data size] |
JPEG compressed image |
Defines a bitmap character with JPEG compression. This tag differs from DefineBits in that the record contains both the JPEG encoding table and the JPEG image data (as defined by the Independent JPEG Group). This record allows multiple JPEG images with differing compression ratios to be defined within a single SWF file.
Note: The JPEG encoding data and image data contained within this record are in two separate JPEG streams. Each JPEG stream has a beginning of stream tag (0xFF, 0xD8) and an end of stream tag (0xFF, 0xD9). This differs from a standard JPEG image which combines the encoding data and image data into a single stream. (SWF 2.0)
(See class FDTDefineBitsJPEG2 in the Flash File Format SDK)
DefineBitsJPEG 2 |
||
Field |
Type |
Comment |
Header |
RECORDHEADER |
Tag ID = 21 |
BitmapId |
UI16 |
ID for this character |
BitmapJPEGEncoding |
UI8[encoding data size] |
JPEG encoding table |
BitmapJPEGImage |
UI8[image data size] |
JPEG compressed image |
Defines a bitmap character with JPEG compression. This tag differs from DefineBitsJPEG2 because it contains alpha channel data. This record allows multiple JPEG images with differing compression ratios to be defined within a single SWF file.
Note: The JPEG encoding data and image data contained within this record are in two separate JPEG streams. Each JPEG stream has a beginning of stream tag (0xFF, 0xD8) and an end of stream tag (0xFF, 0xD9). This differs from a standard JPEG image which combines the encoding data and image data into a single stream. (SWF 3.0)
(See class FDTDefineBitsJPEG3 in the Flash File Format SDK)
DefineBitsJPEG3 |
|
|
Field |
Type |
Comment |
Header |
RECORDHEADER |
Tag ID = 35 |
BitmapId |
UI16 |
ID for this character |
Offset |
UI32 |
Count of bytes in
BitmapJPEGEncoding and BitmapJPEGImage. |
BitmapJPEGEncoding |
UI8[encoding data size] |
JPEG encoding table |
BitmapJPEGImage |
UI8[image data size] |
JPEG compressed image |
BitmapAlphaData |
UI8[alpha data size] |
ZLIB compressed array of
alpha data |
Defines a loss-less bitmap character that contains raw ZLIB compressed image data. The data format used by the ZLIB library is described by Request for Comments (RFCs) documents 1950 to 1952. (SWF 2.0)
(See class FDTDefineBitsLossless in the Flash File Format SDK)
DefineBitsLossless |
||
Field |
Type |
Comment |
Header |
RECORDHEADER |
Tag ID = 20 |
BitmapId |
UI16 |
Bitmap ID for this
character |
BitmapFormat |
UI8 |
Format of compressed data |
BitmapWidth |
UI16 |
Width of bitmap image |
BitmapHeight |
UI16 |
Height of bitmap image |
BitmapColorTableSize |
if BitmapFormat == 3 UI8 if BitmapFormat == 4 UI16 if BitmapFormat == 5 UI32 |
This value is one less than
the actual size of the color table. |
ZlibBitmapData |
ZLIBBITMAPDATA |
ZLIB compressed bitmap data |
The ZlibBitmapData field contains both colormap and pixel data. The ZLIBBITMAPDATA structure is compressed as a single unit. Before being compressed the ZLIBBITMAPDATA structure looks like this:
ZLIBBITMAPDATA |
||
Field |
Type |
Comment |
ColorTableRGB |
RGB[color table size] |
Defines the mapping from
color indices to RGB values. Color
table size is BitmapColorTableSize + 1. |
BitmapPixelData |
UI8[image data size] |
Array of color
indices. Image data size is
BitmapWidth * BitmapHeight * BytesPerPixel.
|
Note: Scan lengths must be rounded up to the next 32-bit word boundary. For example, an 8 bit image that is 253 pixels wide, must be padded out to 256 bytes per line.
DefineBitsLossless2 extends DefineBitsLossless by including an alpha value in the Color Table. Defines a loss-less bitmap character that contains raw ZLIB compressed image data and alpha channel information. The data format used by the ZLIB library is described by Request for Comments (RFCs) documents 1950 to 1952. (SWF 3.0)
(See class FDTDefineBitsLossless2 in the Flash File Format SDK)
DefineBitsLossless2 |
||
Field |
Type |
Comment |
Header |
RECORDHEADER |
Tag ID = 36 |
BitmapId |
UI16 |
Bitmap ID for this
character |
BitmapFormat |
bmFormat = UI8 |
Format of compressed data |
BitmapWidth |
UI16 |
Width of bitmap image |
BitmapHeight |
UI16 |
Height of bitmap image |
BitmapColorTableSize |
if BitmapFormat == 3 UI8 if BitmapFormat == 4 UI16 if BitmapFormat == 5 UI32 |
This value is one less than
the actual size of the color table. |
ZLIBBITMAPDATA2 |
ZLIB compressed bitmap data |
The ZlibBitmapData2 field contains both colormap and pixel data. The ZLIBBITMAPDATA2 structure is compressed as a single unit. Before being compressed the ZLIBBITMAPDATA2 structure looks like this:
ZLIBBITMAPDATA2 |
||
Field |
Type |
Comment |
ColorTableRGBA |
RGBA[color table size] |
Defines the mapping from
color indices to RGBA values. Color
table size is BitmapColorTableSize + 1. |
BitmapPixelData |
UI8[image data size] |
Array of color
indices. Image data size is BitmapWidth
* BitmapHeight * BytesPerPixel. |
Note: Scan lengths must be rounded up to the next 32-bit word boundary. For example, an 8 bit image that is 253 pixels wide, must be padded out to 256 bytes per line.
Defines the JPEG encoding table (as defined by the Independent JPEG Group) for the JPEG images defined using the DefineBits records. There should only be one record of this type in a SWF file. (SWF 1.0)
(See class FDTJPEGTables in the Flash File Format SDK)
JPEGTables |
||
Field |
Type |
Comment |
Header |
RECORDHEADER |
Tag ID = 8 |
BitmapJPEGEncoding |
UI8[encoding data size] |
JPEG encoding table |
The SDK contains C++ examples that demonstrate how to define bitmaps in SWF:
· FExampleBitsLossless.cpp generates an 8-bit indexed bitmap in a memory buffer, and uses the low-level manager to create a FDTDefineBitsLossless image object. A rectangle the same size as the bitmap is defined, and filled with the bitmap.
· FExampleBitsJpeg.cpp reads a 24-bit RGB JPEG file into memory, and uses the low-level manager to create a FDTDefineBitsJpeg2 image object. A rectangle the same size as the bitmap is defined, and filled with the bitmap.