L_AgingBitmap

#include "l_bitmap.h"

L_LTIMGSFX_API L_INT L_AgingBitmap (pBitmap, uHScratchCount, uVScratchCount, uMaxScratchLen, uDustDensity, uPitsDensity, uMaxPitSize, crScratch, crDust, crPits, uFlags)

Adds effects that simulate random color changes, scratches, dust and pits, making a bitmap look like it was made from an old film.

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle referencing the bitmap to be changed.

L_UINT uHScratchCount

Number of horizontal scratch lines.

L_UINT uVScratchCount

Number of vertical scratch lines.

L_UINT uMaxScratchLen

Maximum scratch line length, in pixels. Its minimum value is 2.

L_UINT 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.)

L_UINT 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.)

L_UINT uMaxPitSize

Maximum pit size, in pixels. The size of the pits will be selected at random between 1 and uMaxPitSize.

COLORREF crScratch

A COLORREF value representing the color of the scratch lines.

COLORREF crDust

A COLORREF value representing the color of the dust.

COLORREF crPits

A COLORREF value representing the color of the pits.

L_UINT 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

Value Meaning
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 in the Document and Medical Imaging 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

Platforms

Win32, x64.

See Also

Functions

Topics

Example

This example loads a bitmap and applies the 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 (MAKE_IMAGE_PATH(TEXT("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(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &LeadBitmap, FILE_BMP, 24, 0, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   //free bitmap  
   if(LeadBitmap.Flags.Allocated)   
      L_FreeBitmap(&LeadBitmap);   
   return SUCCESS; 
} 

Help Version 21.0.2023.2.15
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.