L_AntiAliasBitmap

#include "l_bitmap.h"

L_LTIMGEFX_API L_INT L_AntiAliasBitmap(pBitmap, nThreshold, uDim, uFilter, uFlags)

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

L_INT nThreshold;

/* threshold value */

L_UINT uDim;

/* mask size */

L_UINT uFilter;

/* anti-aliasing filter */

L_UINT32 uFlags;

/* flags*/

Applies an anti-aliasing filter to the specified bitmap.

Parameter

Description

pBitmap

Pointer to the bitmap handle that references the bitmap on which to apply the filter.

nThreshold

Threshold value that indicates which pixels to smooth. The application of the anti-aliasing filter on the image associates a value with each pixel. Only pixels with values above this threshold are smoothed.

uDim

Value that indicates the size of the anti-aliasing mask. For example, a value of three indicates an anti-aliasing mask of 3 X 3.

uFilter

Flag that indicates the type of anti-aliasing filter to use. Possible values are:

 

Value

Meaning

 

ANTIALIAS_1

[0x0000] Anti-alias the bitmap vertically and horizontally.

 

ANTIALIAS_2

[0x0001] Anti-alias the bitmap in all directions.

 

ANTIALIAS_3

[0x0002] Anti-alias the bitmap in all directions. The filter used for this option is different from the filter used for the ANTIALIAS_2 option.

 

ANTIALIAS_DIAG

[0x0003] Anti-alias the bitmap diagonally.

 

ANTIALIAS_HORZ

[0x0004] Anti-alias the bitmap horizontally.

 

ANTIALIAS_VERT

[0x0005] Anti-alias the bitmap vertically.

uFlags

Reserved for future use. Must be 0.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

This function can process the whole image or a region of the image.

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 best results for anti-aliasing text can be obtained with the filter ANTIALIAS_2.

The value of the uDim parameter determines the extent of the anti-aliasing.

The threshold range for 16, 48 and 64-bit images is from 0 to 65535 for unsigned images, and from –32768 to +32767 for signed images. For 12-bit images, the threshold range is from 0 to 4095 for unsigned images, and from –2048 to +2047 for signed images. Otherwise, it is from 0 to 255. The threshold is applied to channels separately.

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

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

Windows 2000 / XP/Vista.

See Also

Functions:

L_AdjustBitmapTint, L_ColorHalfToneBitmap

Topics:

Correcting Colors

 

Raster Image Function: Filtering Images

 

Raster Image Functions: Correcting Colors

Example

#if defined (LEADTOOLS_V16_OR_LATER)
 L_INT AntiAliasBitmapExample(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("%UserProfile%\\My Documents\\LEADTOOLS Images\\IMAGE1.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
   if(nRet !=SUCCESS)
      return nRet;
   /* do the anti-aliasing on the bitmap */
   nRet = L_AntiAliasBitmap (&LeadBitmap, 128, 3, ANTIALIAS_1, 0);
   if(nRet !=SUCCESS)
      return nRet;
   nRet = L_SaveBitmap(TEXT("%UserProfile%\\My Documents\\LEADTOOLS 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;
}
#else
 L_INT AntiAliasBitmapExample(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("%UserProfile%\\My Documents\\LEADTOOLS Images\\IMAGE1.CMP"), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL);
   if(nRet !=SUCCESS)
      return nRet;
   /* do the anti-aliasing on the bitmap */
   nRet = L_AntiAliasBitmap (&LeadBitmap, 128, 3, ANTIALIAS_1);
   if(nRet !=SUCCESS)
      return nRet;
   nRet = L_SaveBitmap(TEXT("%UserProfile%\\My Documents\\LEADTOOLS 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;
}
#endif // LEADTOOLS_V16_OR_LATER