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. This function is available in the Medical toolkits.

Parameter

Description

pBitmap

Pointer to the bitmap handle referencing the main bitmap.

nIndex

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

uFlags

Flags that determine whether the main bitmap or the overlay bitmap should be updated. You can or SETOVERLAYBITS_FROMOVERLAY and SETOVERLAYBITS_CLEAR. Possible values are:

 

Value

Meaning

 

SETOVERLAYBITS_FROMOVERLAY

[0x0001] Update the main bitmaps bits for the corresponding bitplane using the data from 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 bits from the bitplane associated with the overlay that are not contained in the overlay bitmap (use only in combination with SETOVERLAYBITS_FROMOVERLAY)

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

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

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

Windows 2000 / XP/Vista.

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, TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\overlay.bmp"), 0, RGB(0, 0, 255));   // blue
   if(nRet != SUCCESS)
   {
      MessageBox(hWnd, TEXT("Error Loading Overlay 0!"), TEXT("Error"), MB_OK);
      return nRet;
   }

   nRet = L_UpdateBitmapOverlayBits(pBitmap, 0, SETOVERLAYBITS_FROMOVERLAY);
   if(nRet != SUCCESS)
   {
      MessageBox(hWnd, TEXT("Error setting Overlay 0!"), TEXT("Error"), MB_OK);
      return nRet;
   }

   L_FreeBitmap(pBitmap);

   return SUCCESS;
}