2.3.1.1 EMR_ALPHABLEND Record
The EMR_ALPHABLEND record specifies a block transfer of pixels from a source bitmap to a destination rectangle, including alpha transparency data, according to a specified blending operation.<56>
Fields not specified in this section are specified in section 2.3.1.
|
|
|
|
|
|
|
|
|
|
1 |
|
|
|
|
|
|
|
|
|
2 |
|
|
|
|
|
|
|
|
|
3 |
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type |
|||||||||||||||||||||||||||||||
Size |
|||||||||||||||||||||||||||||||
Bounds |
|||||||||||||||||||||||||||||||
... |
|||||||||||||||||||||||||||||||
... |
|||||||||||||||||||||||||||||||
... |
|||||||||||||||||||||||||||||||
xDest |
|||||||||||||||||||||||||||||||
yDest |
|||||||||||||||||||||||||||||||
cxDest |
|||||||||||||||||||||||||||||||
cyDest |
|||||||||||||||||||||||||||||||
BLENDFUNCTION |
|||||||||||||||||||||||||||||||
xSrc |
|||||||||||||||||||||||||||||||
ySrc |
|||||||||||||||||||||||||||||||
XformSrc (24 bytes) |
|||||||||||||||||||||||||||||||
... |
|||||||||||||||||||||||||||||||
... |
|||||||||||||||||||||||||||||||
... |
|||||||||||||||||||||||||||||||
BkColorSrc |
|||||||||||||||||||||||||||||||
UsageSrc |
|||||||||||||||||||||||||||||||
offBmiSrc |
|||||||||||||||||||||||||||||||
cbBmiSrc |
|||||||||||||||||||||||||||||||
offBitsSrc |
|||||||||||||||||||||||||||||||
cbBitsSrc |
|||||||||||||||||||||||||||||||
cxSrc |
|||||||||||||||||||||||||||||||
cySrc |
|||||||||||||||||||||||||||||||
BitmapBuffer (variable) |
|||||||||||||||||||||||||||||||
... |
Type (4 bytes): An unsigned integer that identifies this record type as EMR_ALPHABLEND. This value is 0x00000072.
Bounds (16 bytes): A RectL object ([MS-WMF] section 2.2.2.19) that specifies the destination bounding rectangle in logical coordinates. If the intersection of this rectangle with the current clipping regions (section 3.1.1.2.1) in the playback device context (section 3.1) is empty, this record has no effect.
xDest (4 bytes): A signed integer that specifies the logical x-coordinate of the upper-left corner of the destination rectangle.
yDest (4 bytes): A signed integer that specifies the logical y-coordinate of the upper-left corner of the destination rectangle.
cxDest (4 bytes): A signed integer that specifies the logical width of the destination rectangle. This value MUST be greater than zero.
cyDest (4 bytes): A signed integer that specifies the logical height of the destination rectangle. This value MUST be greater than zero.
BLENDFUNCTION (4 bytes): A structure that specifies the blending operations for source and destination bitmaps.
-
0
1
2
3
4
5
6
7
8
91
0
1
2
3
4
5
6
7
8
92
0
1
2
3
4
5
6
7
8
93
0
1BlendOperation
BlendFlags
SrcConstantAlpha
AlphaFormat
-
BlendOperation (1 byte): The blend operation code. The only source and destination blend operation that has been defined is 0x00, which specifies that the source bitmap MUST be combined with the destination bitmap based on the alpha transparency values of the source pixels. See the following equations for details.
-
BlendFlags (1 byte): This value is 0x00 and MUST be ignored.
-
SrcConstantAlpha (1 byte): An unsigned integer that specifies alpha transparency, which determines the blend of the source and destination bitmaps. This value MUST be used on the entire source bitmap. The minimum alpha transparency value, zero, corresponds to completely transparent; the maximum value, 0xFF, corresponds to completely opaque. In effect, a value of 0xFF specifies that the per-pixel alpha values determine the blend of the source and destination bitmaps. See the equations later in this section for details.
-
AlphaFormat (1 byte): A structure that specifies how source and destination pixels are interpreted with respect to alpha transparency.
-
Value
Meaning
0x00
The pixels in the source bitmap do not specify alpha transparency. In this case, the SrcConstantAlpha value determines the blend of the source and destination bitmaps. Note that in the following equations SrcConstantAlpha is divided by 255, which produces a value in the range 0 to 1.
AC_SRC_ALPHA
0x01
Indicates that the source bitmap is 32 bits-per-pixel and specifies an alpha transparency value for each pixel.
-
xSrc (4 bytes): A signed integer that specifies the logical x-coordinate of the upper-left corner of the source rectangle.
ySrc (4 bytes): A signed integer that specifies the logical y-coordinate of the upper-left corner of the source rectangle.
XformSrc (24 bytes): An XForm object (section 2.2.28) that specifies a world-space to page-space transform to apply to the source bitmap.
BkColorSrc (4 bytes): A ColorRef object ([MS-WMF] section 2.2.2.8) that specifies the background color of the source bitmap.
UsageSrc (4 bytes): An unsigned integer that specifies how to interpret values in the color table in the source bitmap header. This value is in the DIBColors enumeration (section 2.1.9).
offBmiSrc (4 bytes): An unsigned integer that specifies the offset in bytes from the start of this record to the source bitmap header in the BitmapBuffer field.
cbBmiSrc (4 bytes): An unsigned integer that specifies the size in bytes of the source bitmap header.
offBitsSrc (4 bytes): An unsigned integer that specifies the offset in bytes from the start of this record to the source bitmap bits in the BitmapBuffer field.
cbBitsSrc (4 bytes): An unsigned integer that specifies the size in bytes of the source bitmap bits.
cxSrc (4 bytes): A signed integer that specifies the logical width of the source rectangle. This value MUST be greater than zero.
cySrc (4 bytes): A signed integer that specifies the logical height of the source rectangle. This value MUST be greater than zero.
BitmapBuffer (variable): A buffer containing the source bitmap, which is not required to be contiguous with the fixed portion of the EMR_ALPHABLEND record. Thus, fields in this buffer that are labeled "UndefinedSpace" are optional and MUST be ignored.
-
0
1
2
3
4
5
6
7
8
91
0
1
2
3
4
5
6
7
8
92
0
1
2
3
4
5
6
7
8
93
0
1UndefinedSpace1 (variable, optional)
...
BmiSrc (variable)
...
UndefinedSpace2 (variable, optional)
...
BitsSrc (variable)
...
-
BmiSrc (variable): The source bitmap header.
-
BitsSrc (variable): The source bitmap bits.
The following equations show how destination pixels are computed from source pixels using BLENDFUNCTION. In the equations, "dst" refers to the destination bitmap, and "src" refers to the source bitmap. The color and transparency values of the source and destination pixels are denoted by "Red", "Green", "Blue", and "Alpha".
Case I: The AlphaFormat value is 0, which means the SrcConstantAlpha value MUST be used to blend the source and destination bitmaps, as follows.
-
dst.Red = src.Red * (SrcConstantAlpha/255.0) + dst.Red * (1.0 - (SrcConstantAlpha/255.0)) dst.Green = src.Green * (SrcConstantAlpha/255.0) + dst.Green * (1.0 - (SrcConstantAlpha/255.0)) dst.Blue = src.Blue * (SrcConstantAlpha/255.0) + dst.Blue * (1.0 - (SrcConstantAlpha/255.0))
If the destination bitmap has an alpha channel, then it is blended as follows.
-
dst.Alpha = src.Alpha * (SrcConstantAlpha/255.0) + dst.Alpha * (1.0 - (SrcConstantAlpha/255.0))
Note that if SrcConstantAlpha is 0xFF, these equations reduce to a simple source copy to the destination.
Case II: The AlphaFormat value is AC_SRC_ALPHA, which means the source pixels MUST be premultiplied by SrcConstantAlpha, and then the blend MUST be based on the per-pixel source alpha channel, as follows.
-
src.Red = src.Red * (SrcConstantAlpha/255.0) src.Green = src.Green * (SrcConstantAlpha/255.0) src.Blue = src.Blue * (SrcConstantAlpha/255.0) dst.Red = src.Red + (1.0 - (src.Alpha/255.0)) * dst.Red dst.Green = src.Green + (1.0 - (src.Alpha/255.0)) * dst.Green dst.Blue = src.Blue + (1.0 - (src.Alpha/255.0)) * dst.Blue
If the destination bitmap has an alpha channel, it is blended as follows.
-
src.Alpha = src.Alpha * (SrcConstantAlpha)/255.0) dst.Alpha = src.Alpha + (1.0 - (src.Alpha/255.0)) * dst.Alpha
If SrcConstantAlpha is 0xFF, there is in effect no premultiplication of the source values.
See section 2.3.1 for more bitmap record types.