(swf file format spec v10)swf文件格式中英文说明书v10,颜色记录,笔记6

最枯燥的部分终于要结束了,马上就要迎来很关键的部分,不过这之前都是后面要深入了解的基础。

RGB color record
The RGB record represents a color as a 24-bit red, green, and blue value.
RGB颜色记录
RGB颜色记录代表颜色用一个24 bit 的红、绿、蓝的值。

Red UI8 Red color value
Green UI8 Green color value
Blue UI8 Blue color value

RGBA color with alpha record
The RGBA record represents a color as 32-bit red, green, blue and alpha value. An RGBA
color with an alpha value of 255 is completely opaque. An RGBA color with an alpha value of
zero is completely transparent. Alpha values between zero and 255 are partially transparent.
带有alpha通道的RGBA颜色块
这个RGBA颜色记录用一个32bit的红、绿、蓝和透明的颜色代表。一个带有透明值为255的RGBA颜色是不透明的。一个带有透明值为0的RGBA色是透明的。透明值将在0—255之间描述透明度。


Red    UI8   Red color value
Green   UI8   Green color value
Blue   UI8    Blue color value
Alpha   UI8   Transparency color value

ARGB color with alpha record
The ARGB record behaves exactly like the RGBA record, but the alpha value for the ARGB record is in the first byte.
带有alpha的ARGB颜色记录
ARGB与RGBA相当类似,只不过在ARGB颜色记录中,透明度是第一个值。

Alpha   UI8   Transparency color value
Red   UI8   Red color value
Green   UI8   Green color value
Blue   UI8   Blue color value

Rectangle record
A rectangle value represents a rectangular region defined by a minimum x- and y-coordinate position and a maximum x- and y-

coordinate position. The RECT record must be byte aligned.
矩形块
一组矩形值,用X、Y最小坐标值和X、Y最大坐标值来描述一个矩形区域,这个RECT块必须按字节对齐。

Nbits    UB[5] Bits used for each subsequent field 描述后继域所使用的bit数
Xmin   SB[Nbits] x minimum position for rectangle in twips X(以twips为单位)最小位置坐标
Xmax SB[Nbits] x maximum position for rectangle in twips X(以twips为单位)最大位置坐标
Ymin SB[Nbits] y minimum position for rectangle in twips Y(以twips为单位)最小位置坐标
Ymax   SB[Nbits] y maximum position for rectangle in twips Y(以twips为单位)最大位置坐标


MATRIX record
The MATRIX record represents a standard 2x3 transformation matrix of the sort commonly used in 2D graphics. It is used to describe the scale, rotation, and translation of a graphic object. The MATRIX record must be byte aligned.
矩阵记录
矩阵记录代表一个标准2x3的用于普通二维图形的变换矩阵类。它一般用于描述一个图形对象的缩放、旋转和转换。这个矩阵记录必须字节对齐。

HasScale   UB[1]   Has scale values if equal to 1 位,是否设定缩放,如果缩放置1.
NScaleBits If HasScale = 1, UB[5] Bits in each scale value field 如果缩放,设定每一个缩放值域的位数。
ScaleX If HasScale = 1, FB[NScaleBits]   x scale value X缩放值
ScaleY If HasScale = 1, FB[NScaleBits]   y scale value Y缩放值
HasRotate UB[1] Has rotate and skew values if equal to 1 位,是否设定旋转和扭曲,如果旋转和扭曲置1.
NRotateBits If HasRotate = 1, UB[5] Bits in each rotate value field 如果旋转,设定每一个旋转值域的位数。
RotateSkew0 If HasRotate = 1, FB[NRotateBits]   First rotate and skew value 第一个旋转和扭曲的值
RotateSkew1 If HasRotate = 1, FB[NRotateBits] Second rotate and skew value 第二个旋转和扭曲的值
NtranslateBits UB[5]   Bits in each translate value field 设定每一个转换值域的位数。
TranslateX   SB[NTranslateBits] x translate value in twips X转换
TranslateY   SB[NTranslateBits] y translate value in twips Y转换

The ScaleX, ScaleY, RotateSkew0 and RotateSkew1 fields are stored as 16.16 fixed-point values. The TranslateX and TranslateY values are stored as signed values in twips.
其中ScaleX, ScaleY, RotateSkew0 和 RotateSkew1域的值以16.16定点数形式存储。TranslateX and TranslateY域的值以带符号数用twips形式存储。

The MATRIX record is optimized for common cases such as a matrix that performs a
translation only. In this case, the HasScale and HasRotate flags are zero, and the matrix only
contains the TranslateX and TranslateY fields.
一个矩阵记录在通常状态下被优化了,例如仅包含转换。在这种情况下,HasScale 和 HasRotate标志位为0,并且这个矩阵仅包含TranslateX 和 TranslateY域。

The mapping from the MATRIX fields to the 2x3 matrix is as follows:
(一个从矩阵域值映像成2x3的矩阵如下:)
ScaleX    RotateSkew0
RotateSkew1   ScaleY
TranslateX   TranslateY

For any coordinates (x, y), the transformed coordinates (x', y') are calculated as follows:
(对于任何(x, y)坐标,转换坐标(x', y')计算如下:)
x' = x * ScaleX + y * RotateSkew1 + TranslateX
y' = x * RotateSkew0 + y * ScaleY + TranslateY

The following table describes how the members of the matrix are used for each type of operation:
(下面这个表描述了对于每一种类型操作,将有多少矩阵成员被利用:)

operation ScaleX   RotateSkew0   RotateSkew1   ScaleY
Rotation Cosine    Sine     Negative    sine Cosine
Scaling   Horizontal Nothing     Nothing   Vertical scaling
scaling              component
component
Shear   Nothing   Horizontal    Vertical   Nothing
Proportionality proportionality
Constant    constant
Reflection Horizontal Nothing     Nothing Vertical reflection
Reflection           component
Component

Color transform record
The CXFORM record defines a simple transform that can be applied to the color space of a graphic object. The following are

the two types of transform possible:
■ Multiplication transforms 乘法转换
■ Addition transforms 加法转换

颜色转换记录
这个CXFORM记录定义了一个简单转换,能应用于一个图形对象的颜色空间。这种转换有以下两种类型:
■ 乘法转换
■ 加法转换

Multiplication transforms multiply the red, green, and blue components by an 8.8 fixed-point multiplication term. The fixed-point representation of 1.0 is 0x100 or 256 decimal.
通过8.8定点乘法公式乘以红、绿、蓝组件。1.0的定点表示是0x100 或 256。

Multiplication transforms(乘法转换)
For any color (R,G,B), the transformed color (R', G', B') is calculated as follows:
(对于任何颜色(R、G、B),转换后的颜色(R'、 G'、B')计算如下:)
R' = (R * RedMultTerm) / 256
G' = (G * GreenMultTerm) / 256
B' = (B * BlueMultTerm) / 256

Addition transforms add an addition term (positive or negative) to the red, green, and blue components of the object being displayed. If the result is greater than 255, the result is clamped to 255. If the result is less than zero, the result is clamped to zero.
加法转换为正在显示对象的红、绿、蓝组件加上一个固定的加法公式(正或负)。如何这个结果大于255,将固定(截断)为255。如这个结果小于0,将固定(截断)为0。

For any color (R,G,B), the transformed color (R', G', B') is calculated as follows:
(对于任何颜色(R、G、B),转换后的颜色(R'、 G'、B')计算如下:)
R' = max(0, min(R + RedAddTerm, 255))
G' = max(0, min(G + GreenAddTerm, 255))
B' = max(0, min(B + BlueAddTerm, 255))

Addition and multiplication transforms can be combined as follows. The multiplication operation is performed first:
(加法和乘法转换如下列被组合在一下。乘法操作被指定为优先项:)
R' = max(0, min(((R * RedMultTerm) / 256) + RedAddTerm, 255))
G' = max(0, min(((G * GreenMultTerm) / 256) + GreenAddTerm, 255))
B' = max(0, min(((B * BlueMultTerm) / 256) + BlueAddTerm, 255))
The CXFORM record must be byte aligned.(这个CXFORM块必须字节对齐。)

CXFORM
Field      Type        Comment
HasAddTerms UB[1] Has color addition values if equal to 1 颜色加法转换标志位,有则置1。
HasMultTerms UB[1] Has color multiply values if equal to 1 颜色乘法转换标志位,有则置1。
Nbits     UB[4]   Bits in each value field 每一个值域使用的位数。
RedMultTerm   If HasMultTerms = 1, SB[Nbits] Red multiply value 红色乘法值
GreenMultTerm If HasMultTerms = 1, SB[Nbits] Green multiply value绿色乘法值
BlueMultTerm   If HasMultTerms = 1, SB[Nbits] Blue multiply value蓝色乘法值
RedAddTerm   If HasAddTerms = 1, SB[Nbits] Red addition value红色加法值
GreenAddTerm   If HasAddTerms = 1, SB[Nbits] Green addition value 绿色加法值
BlueAddTerm   If HasAddTerms = 1, SB[Nbits] Blue addition value蓝色加法值

Color transform with alpha record
The CXFORMWITHALPHA record extends the functionality of CXFORM by allowing color transforms to be applied to the alpha channel, as well as the red, green, and blue channels. The following are the two types of transform possible:
■ Multiplication Transforms
■ Addition Transforms

带有透明度的颜色转换
这个CXFORMWITHALPHA记录扩展了CXFORM功能,以支持在进行颜色转换时alpha通道,当然还有红、绿、蓝通道。这种转换有以下两种类型:
■ 乘法转换
■ 加法转换

Multiplication transforms multiply the red, green, blue, and alpha components by an 8.8 fixed-point value. The fixed-point representation of 1.0 is 0x100 or 256 decimal. Therefore, the result of a multiplication operation should be divided by 256.
通过8.8定点乘法定值乘以红、绿、蓝和透明度组件。1.0的定点表示是0x100 或 256.因此一个乘法操作将要被256整除。

Multiplication transforms(乘法转换)
For any color (R,G,B,A), the transformed color (R', G', B', A') is calculated as follows:
(对于任何颜色(R,G,B,A),转换后的颜色(R', G', B', A')计算如下:)
R' = (R * RedMultTerm) / 256
G' = (G * GreenMultTerm) / 256
B' = (B * BlueMultTerm) / 256
A' = (A * AlphaMultTerm) / 256

The CXFORMWITHALPHA record is most commonly used to display objects as partially transparent, achieved by multiplying the alpha channel by some value between zero and 256.
这个CXFORMWITHALPHA记录经常用于部分透明地显示对象,通过乘以0—256之间的一些值来实现alpha通道效果。

Addition transforms add a fixed value (positive or negative) to the red, green, blue, and alpha components of the object being displayed. If the result is greater than 255, the result is clamped to 255. If the result is less than zero, the result is clamped to zero.
加法转换为正在显示对象的红、绿、蓝、透明组件加上一个固定的加法公式(正或负)。如何这个结果大于255,将固定为255。如果结果小于0,将固定为0。
For any color (R,G,B,A), the transformed color (R', G', B', A') is calculated as follows:
(对于任何颜色(R,G,B,A),转换后的颜色(R', G', B', A')计算如下:)
R' = max(0, min(R + RedAddTerm, 255))
G' = max(0, min(G + GreenAddTerm, 255))
B' = max(0, min(B + BlueAddTerm, 255))
A' = max(0, min(A + AlphaAddTerm, 255))

Addition and multiplication transforms can be combined as follows. The multiplication operation is performed first:
(加法和乘法转换如下列被组合在一下。乘法操作被指定为优先项:)
R' = max(0, min(((R * RedMultTerm) / 256) + RedAddTerm, 255))
G' = max(0, min(((G * GreenMultTerm) / 256) + GreenAddTerm, 255))
B' = max(0, min(((B * BlueMultTerm) / 256) + BlueAddTerm, 255))
A' = max(0, min(((A * AlphaMultTerm) / 256) + AlphaAddTerm, 255))
Like the CXFORM record,the CXFORMWITH ALPHA record is byte aligned.(跟CXFORM记录一样,CXFORMWITH ALPHA记录也是字节对齐的。)

CXFORMWITHALPHA
Field      Type         Comment
HasAddTerms   UB[1]    Has color addition values if equal to 1 颜色加法转换标志位,有则置1。
HasMultTerms   UB[1]    Has color multiply values if equal to 1 颜色加法转换标志位,有则置1。
Nbits      UB[4]    Bits in each value field 每一个值域使用的位数。
RedMultTerm If HasMultTerms = 1, SB[Nbits] Red multiply value 红色乘值
GreenMultTerm If HasMultTerms = 1, SB[Nbits] Green multiply value 绿色乘值
BlueMultTerm If HasMultTerms = 1, SB[Nbits] Blue multiply value 蓝色乘值
AlphaMultTerm If HasMultTerms = 1, SB[Nbits] Alpha multiply value 透明乘值
RedAddTerm If HasAddTerms = 1, SB[Nbits] Red addition value   红色加值
GreenAddTerm If HasAddTerms = 1, SB[Nbits] Green addition value 绿色加值
BlueAddTerm If HasAddTerms = 1, SB[Nbits] Blue addition value 蓝色加值
AlphaAddTerm If HasAddTerms = 1, SB[Nbits] Transparency addition value透明加值

你可能感兴趣的:(format)