#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_HalfToneBitmap(pBitmap, uType, nAngle, uDim, hList, uFlags)


Pointer to the bitmap handle

L_UINT uType;

Type of halftoning to do

L_INT32 nAngle;

Angle of rotation

L_UINT uDim;

Size of the grain


Handle to the list of bitmaps

L_UINT32 uFlags;


Converts a 1-, 4-, 8-, 16-, 24-, or 32-bit bitmap to a halftoned bitmap, with a specified pattern rotation. A halftoned bitmap is a 1-bit bitmap that has been dithered for black and white printing or display.

Parameter Description
pBitmap Pointer to the bitmap handle referencing the bitmap to be converted.
uType Value that indicates the type of halftoning to perform. Possible values are:
  Value Meaning
  HT_PRINT [0x0000] Halftone for printing
  HT_VIEW [0x0001] Halftone for display
  HT_RECT [0x0002] Rectangular halftone
  HT_CIRC [0x0003] Circular halftone
  HT_ELLIPS [0x0004] Elliptical halftone
  HT_RAND [0x0005] Random halftone
  HT_LINEAR [0x0006] Linear halftone
  HT_USERDEF [0x0007] User defined halftone
nAngle The angle of rotation, expressed in hundredths of degrees. A value of 0 produces a horizontal halftone pattern. This parameter specifies the number of degrees to change the pattern. Positive values rotate the pattern clockwise; negative values rotate the pattern counterclockwise. This value is ignored if the selected halftone pattern is HT_RECT, HT_CIRC or HT_RAND or HT_USERDEF.
uDim Value that indicates the size of the grain. This value is ignored if the selected halftone pattern is HT_VIEW or HT_PRINT. If the pattern is not HT_VIEW or HT_PRINT, uDim should be >= 1. If this parameter is < 1 this function will return ERROR_INV_PARAMETER (-13).
hList Handle to the list of bitmaps that will be used in half toning if the HT_USERDEF option is selected.
uFlags Reserved for future use. Must be 0.



The function was successful.

< 1

An error occurred. Refer to Return Codes.


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.

For the HT_USERDEF option, the number of bitmaps in the list must be at least equal to (uDim * uDim + 1). Bitmaps with higher indexes correspond to higher intensity values.

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

This function does not support 12 and 16-bit grayscale and 48 and 64-bit color images.

To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.

This function supports 32-bit grayscale images.

Required DLLs and Libraries


For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.


Win32, x64, Linux.

See Also


L_DefaultDithering, L_GrayScaleBitmap, L_GrayScaleBitmapExt, L_DlgHalftone, L_AutoColorLevelBitmap, L_ColorLevelBitmap, L_CorrelationBitmap, L_GrayScaleToDuotone, L_GrayScaleToMultitone, L_HolesRemovalBitmapRgn, L_SelectiveColorBitmap, L_SkeletonBitmap


Raster Image Functions: Doing Color Expansion or Reduction


Color Halftone and Halftone Images


#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
L_INT HalfToneBitmapExample(L_VOID) 
   L_INT nRet; 
   BITMAPHANDLE LeadBitmap;   /* Bitmap handle for the image */ 
   BITMAPHANDLE TmpBitmap;    /* Temporary bitmap for building the list */ 
   HBITMAPLIST      hList; 
   L_INT i; 
   /* Load a bitmap at its own bits per pixel */ 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("sample5.cmp")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet = L_CreateBitmapList(&hList); 
   if(nRet !=SUCCESS) 
      return nRet; 
   for (i = 0; i <= 36; ++ i) 
      nRet = L_CopyBitmap(&TmpBitmap, &LeadBitmap, sizeof(BITMAPHANDLE)); 
      if(nRet !=SUCCESS) 
         return nRet; 
      /* Rotate, using the transparent color as the fill color */ 
      nRet = L_RotateBitmap (&TmpBitmap, 1000 * i, 0, RGB(0,0,0)); 
      if(nRet !=SUCCESS) 
         return nRet; 
      nRet = L_InsertBitmapListItem(hList, (L_UINT)-1, &TmpBitmap); 
      if(nRet !=SUCCESS) 
         return nRet; 
   /* fill hList by at least 26 bitmaps*/ 
   /* Halftone the bitmap */ 
   nRet = L_HalfToneBitmap(&LeadBitmap, HT_USERDEF,0, 5, hList, 0); 
   if(nRet !=SUCCESS) 
      return nRet; 
   nRet = L_DestroyBitmapList(hList); 
   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 
   return SUCCESS; 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help