L_AddBitmaps

Summary

Adds or averages the bitmaps in a list.

Syntax

#include "l_bitmap.h"

L_LTIMGCLR_API L_INT L_AddBitmaps(pBitmap, uStructSize, hList, uFlags)

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle that references the resulting bitmap on which the effect is applied.

L_UINT uStructSize

Size in bytes, of the structure pointed to by pBitmap, for versioning. Use sizeof(BITMAPHANDLE).

HBITMAPLIST hList

Handle to the list of bitmaps.

L_UINT uFlags

Flag that indicates the operation to perform. Possible values are:

Value Meaning
BC_AVG [0x0001] Average the bitmaps in the specified list.
BC_ADD [0x0002] Add the bitmaps in the specified list.

Returns

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

Comments

This operation can be used to add several images of the same view to improve the lightness or brightness of the image. It can also eliminate the random noise contained in these images by doing an average of all bitmaps.

This function performs operations between data byte-by-byte. An image can be any color resolution. pBitmap is assumed to be unallocated. If pBitmap contains a bitmap, you should free it prior to calling this function. L_AddBitmaps will allocate and store the resulting bitmap in pBitmap. The image resulting from this operation is internally copied from the first image in the list, before performing the adding operation. The operations are performed based on the smallest width and height of the input images.

This function supports 12 and 16-bit grayscale and 48 and 64-bit color images. Support for 12 and 16-bit grayscale and 48 and 64-bit color images is available in the Document and Medical Imaging toolkits.

To update a status bar or detect a user interrupt during execution of this function, refer to L_SetStatusCallback.

This function does not support 32-bit grayscale images. It returns the error code ERROR_GRAY32_UNSUPPORTED if a 32-bit grayscale image is passed to this function.

The sign flag in the BITMAPHANDLE structure must be the same for all images listed. That is, all hList images must be either signed or unsigned.

Add Bitmaps Function - Before

Add Bitmaps Function - Before

Add Bitmaps Function - After

Add Bitmaps Function - After

View additional platform support for this Add Bitmaps function.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example creates a bitmap list by taking a bitmap and making copies of it, and rotating each image. Then all of the bitmaps are averaged together.

L_INT AddBitmapsExample(L_VOID) 
{ 
   L_INT nRet; 
   HBITMAPLIST hList;         /* Bitmap list */ 
   BITMAPHANDLE LeadBitmap;   /* Bitmap handle to hold the loaded image. */ 
   BITMAPHANDLE TmpBitmap;    /* Temporary bitmap for manipulating the list */ 
   BITMAPHANDLE ResultBitmap; /* Bitmap resulting from the operation */ 
   L_INT i;                   /* Loop counter */ 
 
   /* Load the bitmap, keeping the bits per pixel of the file */ 
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   /* Create and populate the bitmap list */ 
   nRet = L_CreateBitmapList(&hList); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   for (i = 0; i < 4; i++) 
   { 
      nRet = L_CopyBitmap(&TmpBitmap, &LeadBitmap, sizeof(BITMAPHANDLE)); 
      if (nRet != SUCCESS) 
         return nRet; 
 
      nRet = L_RotateBitmap(&TmpBitmap, i*720, ROTATE_RESAMPLE, RGB(255, 0, 0)); 
      if (nRet != SUCCESS) 
         return nRet; 
 
      nRet = L_InsertBitmapListItem(hList, (L_UINT)-1, &TmpBitmap); 
      if (nRet != SUCCESS) 
         return nRet; 
   } 
 
   /*take the average between all rotated bitmaps and store it in ResultBitmap */ 
   nRet = L_AddBitmaps(&ResultBitmap, sizeof(BITMAPHANDLE), hList, BC_AVG); 
   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); 
 
   L_FreeBitmap(&ResultBitmap); 
 
   return SUCCESS; 
} 

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 API Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.