L_UpdateBitmapOverlayBits

#include "l_bitmap.h"

L_LTKRN_API L_INT L_UpdateBitmapOverlayBits(pBitmap, nIndex, uFlags)

pBITMAPHANDLE pBitmap;

pointer to the main bitmap handle

L_INT nIndex;

overlay index

L_UINT uFlags;

flags that determine which bits to update

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

Parameter

Description

pBitmap

Pointer to the main bitmap handle.

nIndex

Overlay index

uFlags

Flags that determine which bits to update

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

The bitmap's memory must be locked when you use this function. Normally, call L_AccessBitmap to lock the memory before starting an operation that uses this function and then call L_ReleaseBitmap when the operation is finished.

If SETOVERLAYBITS_FROMOVERLAY is set in uFlags, 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 from the bitplane associated with the overlay are set to 0 if they are not covered by the overlay. If SETOVERLAYBITS_CLEAR is not set, the bits from the bitplane associated with the overlay that are not covered 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) - pOverlayBitmap.ptOrigin.x
OverlayHeight = BITMAPHEIGHT(pBitmap)  pOverlayBitmap.ptOrigin.y

BITMAPWIDTH is a macro which determines the display bitmap width, taking the view perspective into account.

BITMAPHEIGHT is a macro which determines the display bitmap height, taking the view perspective into account.

Required DLLs and Libraries

LTKRN

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

Win32, x64, Linux.

See Also

Functions:

L_SizeBitmap, L_StartResize, L_Resize, L_StopResize, L_SetOverlayBitmap, L_GetOverlayBitmap, L_SetOverlayAttributes, L_GetOverlayAttributes, L_GetOverlayCount, L_BricksTextureBitmap, L_CanvasBitmap, L_DisplaceMapBitmap, L_FragmentBitmap, L_VignetteBitmap

Topics:

Raster Image Functions: Combining Images

 

Overlay Overview

Example

This example will load an overlay bitmap and sets its color and a few attributes It assumes pBitmap is grayscale. It uses the LoadAndSetOverlay function from the L_SetOverlayBitmap example

/* This function will load an overlay bitmap and sets its color and a few attributes */ 
L_INT LoadAndSetOverlay(pBITMAPHANDLE  pBitmap, 
                        LPTSTR         pszName, 
                        L_INT          nIndex, 
                        COLORREF       crColor) 
{ 
   L_INT                nRet; 
   BITMAPHANDLE         OverlayBitmap; 
   OVERLAYATTRIBUTES    OverlayAttributes; 
 
   // load and then set the overlay bitmap 
   nRet = L_LoadBitmap( pszName, &OverlayBitmap,sizeof(BITMAPHANDLE),1,ORDER_RGB,NULL,NULL); 
   if(nRet == SUCCESS) 
      nRet = L_SetOverlayBitmap( pBitmap, nIndex, &OverlayBitmap,OVERLAY_COPY); 
 
   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) (pBitmap->BitsPerPixel - nIndex - 1); 
      nRet = L_SetOverlayAttributes(pBitmap,  
                                    nIndex,  
                                    &OverlayAttributes,  
                                    OVERLAYATTRIBUTES_COLOR    | 
                                    OVERLAYATTRIBUTES_FLAGS    |  
                                    OVERLAYATTRIBUTES_ORIGIN   |  
                                    OVERLAYATTRIBUTES_BITINDEX); 
   } 
   L_FreeBitmap(&OverlayBitmap); 
   return nRet; 
} 
 
L_INT UpdateBitmapOverlayBitsExample(HWND hWnd, pBITMAPHANDLE pBitmap) 
{ 
   L_INT nRet; 
 
   if(pBitmap->BitsPerPixel != 8 && pBitmap->BitsPerPixel != 12 && pBitmap->BitsPerPixel != 16) 
      L_GrayScaleBitmap(pBitmap, 8); 
 
   // load overlay 0 
   nRet = LoadAndSetOverlay(pBitmap, MAKE_IMAGE_PATH(TEXT("ULAY1.BMP")), 0, RGB(0, 0, 255));   // blue 
   if(nRet != SUCCESS) 
   { 
      MessageBox(hWnd, TEXT("Error Loading Overlay 0!"), TEXT("Error"), MB_OK); 
      return nRet; 
   } 
 
   L_AccessBitmap(pBitmap); 
   nRet = L_UpdateBitmapOverlayBits(pBitmap, 0, SETOVERLAYBITS_FROMOVERLAY); 
   L_ReleaseBitmap(pBitmap); 
   if(nRet != SUCCESS) 
   { 
      MessageBox(hWnd, TEXT("Error setting Overlay 0!"), TEXT("Error"), MB_OK); 
      return nRet; 
   } 
 
   L_FreeBitmap(pBitmap); 
 
   return SUCCESS; 
} 

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