L_AgingBitmap
#include "l_bitmap.h"
L_LTIMGSFX_API L_INT L_AgingBitmap (pBitmap, uHScratchCount, uVScratchCount,uMaxScratchLen, uDustDensity, uPitsDensity, uMaxPitSize, crScratch, crDust,crPits, uFlags)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap handle */ |
L_UINT uHScratchCount; |
/* number of horizontal scratch lines */ |
L_UINT uVScratchCount; |
/* number of vertical scratch lines */ |
L_UINT uMaxScratchLen; |
/* maximum scratch line length */ |
L_UINT uDustDensity; |
/* dust density */ |
L_UINT uPitsDensity; |
/* density of pits */ |
L_UINT uMaxPitSize; |
/* maximum pit size */ |
COLORREF crScratch; |
/* color of the scratch lines */ |
COLORREF crDust; |
/* dust color */ |
COLORREF crPits; |
/* color of pits */ |
L_UINT uFlags; |
/* flags */ |
Adds effects that simulate random color changes, scratches, dust and pits, making a bitmap look like it was made from an old film.
Parameter |
Description |
|
pBitmap |
Pointer to the bitmap handle referencing the bitmap to be changed. |
|
uHScratchCount |
Number of horizontal scratch lines. |
|
uVScratchCount |
Number of vertical scratch lines. |
|
uMaxScratchLen |
Maximum scratch line length, in pixels. Its minimum value is 2. |
|
uDustDensity |
Dust density, expressed in tenths of percent of the bitmap area. Valid values range between 0 and 1000. This value is divided internally by 10. If uDustDen = 1000 then dust density = 100% (that is, the number of dust points = the entire bitmap area.) |
|
uPitsDensity |
Density of the pits, expressed in tenths of percent of the bitmap area. Valid values range between 0 and 1000. This value is divided internally by 10. If uPitsDen = 1000 then the density of the pits = 100% (that is, the number of pits = the entire bitmap area.) |
|
uMaxPitSize |
Maximum pit size, in pixels. The size of the pits will be selected at random between 1 and uMaxPitSize. |
|
crScratch |
A COLORREF value representing the color of the scratch lines. |
|
crDust |
A COLORREF value representing the color of the dust. |
|
crPits |
A COLORREF value representing the color of the pits. |
|
uFlags |
Flags that indicate the distortion type and the distortion color. You can use a bitwise OR (|) to specify one or more flags from each group. |
|
|
The following flags indicate the distortion type: |
|
|
Value |
Meaning |
|
AGING_ADD_NOTHING |
[0x0000] Do not add any distortion type. In this case, the bitmap will be changed by random changes in the color intensity. |
|
AGING_ADD_VSCRATCH |
[0x0001] Add vertical scratch lines. |
|
AGING_ADD_HSCRATCH |
[0x0002] Add horizontal scratch lines. |
|
AGING_ADD_DUST |
[0x0004] Add dust. |
|
AGING_ADD_PITS |
[0x0008] Add pits. |
|
The following flags indicate the distortion color: |
|
|
Value |
Meaning |
|
AGING_SCRATCH_INV |
[0x0000] Use pixels color inverse as scratch line color. If this flag is set, crScratch will be ignored. |
|
AGING_SCRATCH_CLR |
[0x0010] Use the crScratch as scratch line color. |
|
AGING_DUST_INV |
[0x0000] Use pixels color inverse as dust color. If this flag is set, crDust will be ignored. |
|
AGING_DUST_CLR |
[0x0020] Use the crDust as dust color. |
|
AGING_PITS_INV |
[0x0000] Use pixels color inverse as the color of the pits. If this flag is set, crPits will be ignored. |
|
AGING_PITS_CLR |
[0x0040] Use the crPits as the color of the pits. |
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.
To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.
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 only in the Document/Medical toolkits.
The width of the scratches is 1 pixel. The length of the scratches is random (between 2 and uMaxScratchLen).
The size of dust particles is 1 pixel (1x1).
The size and shape of pits is selected at random. The pit shapes are random and will be between 1x1 and uMaxPitSize x uMaxPitSize.
The function will also make random changes to the pixels intensities.
This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.
Required DLLs and Libraries
LTIMGSFX 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
Windows 2000 / XP/Vista.
See Also
Example
This example loads a bitmap and applies aging effect
L_INT AgingBitmapExample(L_VOID) { L_INT nRet; BITMAPHANDLE LeadBitmap; /* Bitmap handle to hold the loaded image. */ /* Load the bitmap, keeping the bits per pixel of the file */ nRet = L_LoadBitmap (TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\IMAGE1.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); if(nRet !=SUCCESS) return nRet; /* apply aging effect */ nRet = L_AgingBitmap (&LeadBitmap, 10, 2, 50,2,5,6, RGB(255,255,0), RGB(0,0,0), RGB(0,0,255), AGING_ADD_VSCRATCH | AGING_ADD_PITS | AGING_SCRATCH_INV | AGING_PITS_CLR); if(nRet !=SUCCESS) return nRet; nRet = L_SaveBitmap(TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\Result.BMP"), &LeadBitmap, FILE_BMP, 24, 0, NULL); if(nRet !=SUCCESS) return nRet; //free bitmap if(LeadBitmap.Flags.Allocated) L_FreeBitmap(&LeadBitmap); return SUCCESS; }