This bitmap section describes how Flash handles raster images.
Flash supports a few different image formats: some are standard formats while others are specific to flash. Open Flash refers to theses formats using an "image type" using a MIME type format.
image/jpegimage/gifimage/pngimage/x-swf-partial-jpeg: JPEG file without Tables/Misc chunk. It has to be defined in a DefineJpegTables tag and injected in the first Start Of Frame (SOF) JPEG chunk.image/x-swf-jpeg3: JPEG with alpha mask (see DefineBitsJPEG3): x-ajpeg :: jpeg_size jpeg alphaimage/x-swf-jpeg4: JPEG with alpha mask and deblocking (see DefineBitsJPEG4): x-ajpegd :: jpeg_size deblock jpeg alphaimage/x-swf-lossless1image/x-swf-lossless2Opaque lossless SWF bitmap in the sRGB color space with 8-bit channel depth and dimensions up to (2¹⁶-1)×(2¹⁶-1) pixels.
This format corresponds to the one used by DefineBitsLossless in the SWF spec.
Syntax
SwfBitmap :
{
0x03dimensions colorCountMinusOne zlib(colorMap)
|0x04dimensions zlib(pixMap15)
|0x05dimensions zlib(pixMap24)
}
dimensions :
width height
width :
LE_UINT16
height :
LE_UINT16
Color map encoding (code 0x03):
Syntax
colorCountMinusOne :
UINT8
colorMap(width, height, colors) :
palette(colors) colorMapRow{height}
palette(colors) :
color{colors}
color :
UINT8 UINT8 UINT8
paddedColorMapRow(width, colors) :
colorMapRow PADDING
colorMapRow(width, colors) :
UINT8[where:value < colors]{width}
Pixel map 15 encoding (code 0x04):
Syntax
pixMap15 :
paddedPixMap15Row{height}
paddedPixMap15Row(width) :
pixMap15Row(width) PADDING
pixMap15Row(width) :
pix15{width}
pix15 :
BE_UINT16
Pixel map 24 encoding (code 0x05):
Syntax
pixMap24 :
pixMap24Row{height}
pixMap24Row(width) :
pix24{width}
pix24 :
0x00UINT8 UINT8 UINT8
TODO: Check if the last row needs padding
The intCeil(n, k) function returns the smallest multiple of k greater than or equal to n.
It is used to compute sizes and offsets based on alignment.
Using mathematical notation, the function can be defined as:
# ⌈ x ⌉ represents the ceiling funtion
intCeil(n, k) = k × ⌈ n / k ⌉
It can also be defined using the modulo operator instead of division and ceiling:
intCeil(n, k) = n + k - 1 - ((n - 1) % k)
Example: Data rows of lossless images must be aligned on 4 bytes. This means that padding must be inserted such that the total size is a multiple of 4. The intCeil(n, 4) function returns this total size for n bytes of useful data. If we have 253 bytes of useful data, we must add 3 bytes of padding to reach 256 bytes, hence intCeil(253, 4) == 256.
ℹ Note: If n is already a multiple of k, the result is just n.
SWF bitmap with transparency (alpha channel).