LBitmap::SetOverlay

Summary

Sets the overlay bitmap for a certain index.

Syntax

#include "ltwrappr.h"

virtual L_INT LBitmap::SetOverlay(nIndex, pOverlayBitmap, uFlags)

virtual L_INT LBitmap::SetOverlay(nIndex, pOverlayBitmap, uFlags)

Parameters

L_INT nIndex

The index of the overlay being affected. This index is zero-based.

pBITMAPHANDLE pOverlayBitmap

Pointer to the overlay bitmap handle which contains the new overlay bitmap. This can be NULL, in which case the corresponding overlay bitmap will be freed.

L_UINT uFlags

Flags that determine setting options. Values cannot be combined. Possible values are:

Value Meaning
OVERLAY_COPY [0x0000] Insert a copy of the overlay bitmap into the overlay list. pOverlayBitmap will not be affected.
OVERLAY_NOCOPY [0x0001] Set pOverlayBitmap into the overlay list without making a copy. You should be careful when modifying the overlay bitmap because you can modify/invalidate the entry in the overlay bitmap list.
OVERLAY_MOVE [0x0003] Move pOverlayBitmap into the overlay list. It will also be reset, so you cannot make changes to it. This is recommended over OVERLAY_NOCOPY.

LBitmapBase * pOverlayBitmap

Pointer to the overlay bitmap object which contains the new overlay bitmap. This can be NULL, in which case the corresponding overlay bitmap will be freed.

Returns

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

Comments

The old overlay bitmap from index nIndex is freed. If pOverlayBitmap is NULL, the old overlay bitmap is freed and the size is reset to:

OverlayWidth = BITMAPWIDTH(pBitmap) - nLeft

OverlayHeight = BITMAPHEIGHT(pBitmap) - nTop,

where:

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.

If uFlags is OVERLAY_NOCOPY and the overlay bitmap is allocated, all the members from the pOverlayBitmap structure are copied into the overlay array. This means whenever you update the data from pOverlayBitmap, the overlay bitmap is changed too. Great care should be taken when using this flag because you can invalidate the overlay bitmaphandle stored in the array. For example, if you free the overlay bitmap, the data pointed by the overlay bitmap from the internal array is also freed. But the array does not know that this has happened and thinks the data pointer is still valid. If the overlay bitmap is accessed in some way, a crash will occur. A safer way of quickly setting the data is to use OVERLAY_MOVE.

If uFlags is OVERLAY_MOVE, the data from the pOverlayBitmap is copied into the overlay array and then the pOverlayBitmap structure is erased. This means that you can do anything with the pOverlayBitmap structure and the overlay bitmap stored in the array will be unaffected. This is the most efficient way of setting the overlay bitmap, because no copy will take place.

You can change the size of the overlay bitmap by calling LBitmap::SetOverlay. Note that you can call LBitmap::SetOverlay with an unallocated bitmap. In that case, only the width and height are used from the overlay bitmap. If an overlay bitmap already exists, it will be freed and the new width/height will be set. After doing this, you must call SetOverlayAttributes to allocate the overlay bitmap and populate it with image data from the main bitmap.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

This example will load an overlay bitmap and sets its color and a few attributes

L_INT LBitmap__SetOverlayExample(LBitmap *plBitmap,LPTSTR pszName,L_INT nIndex,COLORREF crColor)  
 
{ 
    
   L_INT                nRet =SUCCESS;  
   LBitmap              OverlayBitmap;  
   OVERLAYATTRIBUTES    OverlayAttributes;  
 
   // load and then set the overlay bitmap 
    nRet =OverlayBitmap.Load( pszName, 1,ORDER_RGB,NULL,NULL); 
    if(nRet !=SUCCESS) 
       return nRet; 
    
    nRet = plBitmap->SetOverlay( nIndex, &OverlayBitmap,OVERLAY_MOVE);  
 
   if(nRet == SUCCESS)  
   { 
      OverlayAttributes.uStructSize = sizeof(OVERLAYATTRIBUTES);  
      OverlayAttributes.crColor = crColor;  
      OverlayAttributes.uFlags = OVERLAY_AUTOPAINT;  
      if(nIndex != 3)   // auto-process all overlays except index 3 
         OverlayAttributes.uFlags |= OVERLAY_AUTOPROCESS;  
      OverlayAttributes.ptOrigin.x = nIndex * 30;  
      OverlayAttributes.ptOrigin.y = nIndex * 10;  
      OverlayAttributes.uBitPosition = (L_UINT16)(plBitmap->GetBitsPerPixel() - nIndex - 1);  
      nRet =plBitmap->SetOverlayAttributes(nIndex,  
                                            &OverlayAttributes,  
                                             OVERLAYATTRIBUTES_COLOR    | 
                                             OVERLAYATTRIBUTES_FLAGS    |  
                                             OVERLAYATTRIBUTES_ORIGIN   |  
                                             OVERLAYATTRIBUTES_BITINDEX); 
      if(nRet !=SUCCESS) 
         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
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.