Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
L_CreateFadedMask
#include "l_bitmap.h"
L_LTIMGEFX_API L_INT L_CreateFadedMask(pBitmap, uStructSize, pMaskBitmap, nLength, nFadeRate, nStepSize, nInflate, uFlags, nMaxGray, crTransparent)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
pBITMAPHANDLE pMaskBitmap; |
/* pointer to a bitmap handle */ |
L_UINT uStructSize; |
/* size in bytes, of the structure pointed to by pMaskBitmap */ |
L_INT nLength; |
/* extent of the fade */ |
L_INT nFadeRate; |
/* fade rate */ |
L_INT nStepSize; |
/* step size */ |
L_INT nInflate; |
/* expansion value */ |
L_UINT uFlags; |
/* flag */ |
L_INT nMaxGray; |
/* maximum value of the fade color */ |
COLORREF crTransparent; |
/* transparent color */ |
Creates a fade mask bitmap in which the color of each pixel is changed with respect to its position in the bitmap. This change depends on the fade rate.
Parameter |
Description |
|
pBitmap |
Pointer to a bitmap handle. This bitmap must have a region. |
|
pMaskBitmap |
Pointer to a bitmap handle that references a 24-bit bitmap in which the fade mask will be created. |
|
uStructSize |
Size in bytes, of the structure pointed to by pMaskBitmap, for versioning. Use sizeof(BITMAPHANDLE). |
|
nLength |
Value that represents the extent of the fade, in pixels. |
|
nFadeRate |
Value that represents the rate at which the color will fade with each step. Values are between 0 and 255. |
|
nStepSize |
Step size at which the color will change. This value is in pixels. |
|
nInflate |
Value used to expand the resulting bitmap. This parameter is valid only when FADE_OUTER is set in the uFlags parameter. |
|
uFlags |
Flags that indicate how the fade mask will be created. Possible values are: |
|
|
Value |
Meaning |
|
FADE_OUTER |
[0x0001] If this flag is set, the fade will be outside the bitmap's region. If this flag is not set, the fade will be inside the bitmap's region. |
|
FADE_DUMPFILL |
[0x0002] If this flag is set, the dump part of the mask will be filled with the dump color. The FADE_FILLCOLOR_START and FADE_WHITETOBLACK flags determine the dump color. If this flag is not set, the dump part is filled with the crTransparent color. |
|
FADE_FILLCOLOR_START |
[0x0004] If this flag is set, the dump color is the color used at the start of the fade. The start color may be white or black, based on the FADE_WHITETOBLACK. If this flag is not set, the dump color is the color at the end of the fade. If the FADE_DUMPFILL flag is not set, this flag is ignored. |
|
FADE_WHITETOBLACK |
[0x0008] If this flag is set, the fade starts with white and changes toward black. If this flag is not set, the fade changes from black to white. |
|
FADE_NOTRANSPARENCY |
[0x0010] If this flag is set, fill the transparency part with a color other than crTransparency. The color is either the same as the dump color, or its opposite, depending on whether the FADE_TRANSPARENCY_DUMPCOLOR flag is set. If the FADE_NOTRANSPARENCY flag is not set, fill the transparency with crTransparency. If the FADE_DUMPFILL flag is not set, this flag is ignored. |
|
FADE_TRANSPARENCY_DUMPCOLOR |
[0x0020] If this flag is set, the transparency color is the same as the dump color. If this flag is not set, the transparency color is the opposite of the dump color. This flag is used only if FADE_NOTRANSPARENCY is set |
nMaxGray |
The maximum value of the fade color. Possible values are between 0 and 255. |
|
crTransparent |
COLORREF variable that contains the transparency color. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.
This function is concerned with the size and shape of the region, not the bitmap itself. Therefore, any bitmap with a region can be used to create a fade mask bitmap. The fade mask bitmap can be used by the L_FeatherAlphaBlendBitmap function to combine two bitmaps with feathering.
If the FADE_OUTER flag is not set, then the size of the fade mask bitmap is equal to the size of a region and the fade progresses toward the center of the region. If the FADE_OUTER flag is set, the size is equal to the size of region plus the nInflate value and the fade starts at the edge of the region and progresses toward the edge of the fade mask bitmap. (The nInflate parameter is used only with FADE_OUTER flag)
In order to use the fade mask bitmap in the L_FeatherAlphaBlendBitmap function the fade mask bitmap must contain three portions:
a) |
A portion in which the output (from the blending function) will be the same as the destination bitmap. This is called the Transparency portion of the mask and its fill with black. |
b) |
A portion in which the output is a combination of the destination and source bitmap. |
c) |
A portion in which the output comes from the source bitmap. This is called the Dump portion of the mask and its filled with white. |
To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.
For examples of fade masks created using various flags, click here.
This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available in the Document and Medical Imaging toolkits.
This function supports 32-bit grayscale images.
Required DLLs and Libraries
LTIMGEFX For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Platforms
Win32, x64.
See Also
Example
For an example, refer to L_FeatherAlphaBlendBitmap.