L_AddMessageToBitmap

#include "l_bitmap.h"

L_LTIMGEFX_API L_INT L_AddMessageToBitmap(pBitmap, pAddMesgInfo, uFlags)

Adds a message (text or file) to the specified bitmap. The message is specified by the pAddMesgInfo parameter.

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle referencing the destination bitmap. This is the bitmap that the function updates.

pADDMESGINFO pAddMesgInfo

Pointer to an ADDMESGINFO structure that contains information about the message that will be added.

L_UINT32 uFlags

Reserved for future use. Must be 0.

Returns

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

Comments

The purpose of this function is for security since the message added will be embedded into the image without any visible changes and the resulting image has the same size as the original.

This function can add message to any type of losslese image such as bmp, tiff, lossless jpeg, and so forth. If used with lossy format types the message may be corrupted or lost.

This function supports 24- and 48-bits images, and 8- and 16-bits grayscale images.

To extract the embedded message use the L_ExtractMessageFromBitmap function.

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.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example loads a bitmap and adds a text message to it

L_INT AddMessageToBitmapExample(L_VOID) 
{ 
   L_INT nRet; 
   BITMAPHANDLE pBitmap; 
   pADDMESGINFO pAddMesgInfo; 
 
   pAddMesgInfo = (pADDMESGINFO) GlobalAllocPtr(GHND, sizeof(ADDMESGINFO)); 
   if(!pAddMesgInfo) 
      return ERROR_NO_MEMORY; 
 
   pAddMesgInfo->uStructSize =  sizeof(ADDMESGINFO); 
   pAddMesgInfo->pStrMsg = (L_TCHAR *) GlobalAllocPtr(GHND, 200); 
   if(!pAddMesgInfo->pStrMsg) 
      return ERROR_NO_MEMORY; 
 
   /* Load the bitmap, keeping the bits per pixel of the file */ 
   nRet = L_LoadBitmap (MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &pBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   lstrcpy(pAddMesgInfo->pStrMsg, TEXT("LEAD Technologies, Inc.")); 
 
   /*Add the above message to image in the default position and with the default password */ 
   nRet = L_AddMessageToBitmap(&pBitmap, pAddMesgInfo, 0); 
   if(nRet !=SUCCESS) 
      return nRet; 
 
   /*Free the temporary buffers. */ 
   if(pAddMesgInfo->pStrMsg) 
      GlobalFreePtr(pAddMesgInfo->pStrMsg); 
 
   if(pAddMesgInfo) 
      GlobalFreePtr(pAddMesgInfo); 
   nRet = L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Result.BMP")), &pBitmap, FILE_BMP, 24, 0, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   //free bitmap  
   if(pBitmap.Flags.Allocated)   
      L_FreeBitmap(&pBitmap); 
   return SUCCESS; 
} 

Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help