L_HalfToneBitmap

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_HalfToneBitmap(pBitmap, uType, nAngle, uDim, hList, 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.

Parameters

pBITMAPHANDLE pBitmap

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

L_UINT 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

L_INT32 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.

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

HBITMAPLIST hList

Handle to the list of bitmaps that will be used in half toning if the HT_USERDEF option is selected.

L_UINT32 uFlags

Reserved for future use. Must be 0.

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.

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

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

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  
   if(LeadBitmap.Flags.Allocated)   
      L_FreeBitmap(&LeadBitmap);   
   
   return SUCCESS; 
} 
Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help