This function can update the overlay bitmap pixels with the bits from the corresponding bitplane of the main bitmap. It can also update the main bitmaps bitplane with the data from the overlay bitmap.


#include "ltwrappr.h"

virtual L_INT LBitmap::UpdateOverlayBits(nIndex, uFlags)


L_INT nIndex

The index of the overlay used in the process. This overlay must have a corresponding bitplane set, otherwise the function will fail and ERROR_OVERLAY_INDEX will be returned. This index is zero-based.

L_UINT uFlags

Flags that determine whether the main bitmap or the overlay bitmap should be updated. You can use a bitwise OR ( | ) to combine SETOVERLAYBITS_FROMOVERLAY and SETOVERLAYBITS_CLEAR. Possible values are:

Value Meaning
SETOVERLAYBITS_FROMOVERLAY [0x0001] Update the main bitmaps bits for corresponding plane using the data for the overlay bitmap.
SETOVERLAYBITS_FROMBITMAP [0x0002] Update the overlay bitmap with the bits from the corresponding bit plane of the main bitmap. Can be or-ed with SETOVERLAYBITS_CLEAR.
SETOVERLAYBITS_CLEAR [0x0004] Clear the bitmap bits not contained in the overlay bitmap (use only in combination with SETOVERLAYBITS_FROMOVERLAY).


Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.


The function will only work for grayscale 8, 12 or 16-bit bitmaps. Support for 12 and 16-bit bitmaps is only in the Medical toolkits.

If SETOVERLAYBITS_FROMOVERLAY is set, the bitplane in the main bitmap will be updated to match the overlay bitmap data. The left and top coordinates for the overlay bitmap are used. If SETOVERLAYBITS_CLEAR is set, the bits uncovered by the overlay bitmap are set to 0. If SETOVERLAYBITS_CLEAR is not set, the bits uncovered by the overlay bitmap are left unchanged.

If SETOVERLAYBITS_FROMBITMAP is set, the overlay bitmap will be updated with the bits from the corresponding bitplane. The size of the overlay bitmap is unchanged if it has ever been set. If the overlay bitmap has never been set, the overlay bitmap will be from left, top coordinate to the bottom-right corner of the bitmap:

OverlayWidth = BITMAPWIDTH(pBitmap) - nLeft
OverlayHeight = BITMAPHEIGHT(pBitmap) - nTop,


nLeft is the left overlay offset.
nTop is the top overlay offset.
BITMAPWIDTH is a macro which determines the display bitmap width, taking the ViewPerspective into account.
BITMAPHEIGHT is a macro which determines the display bitmap height, taking the ViewPerspective into account.

Required DLLs and Libraries


Win32, x64.

See Also




L_INT LBitmap__UpdateOverlayBitsExample(HWND hWnd, LBitmap *plBitmap)  
   L_INT nRet;  
   // Load your bitmap and set overlay.  
   //  ..  
   //  ..  
   //  ..  
   nRet = plBitmap->UpdateOverlayBits( 0, SETOVERLAYBITS_FROMOVERLAY);  
   if(nRet != SUCCESS)  
      MessageBox(hWnd, TEXT("Error setting Overlay 0!"), TEXT("Error"), MB_OK);    
      return nRet; 
   return nRet;  
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help