L_ExtractMessageFromBitmap

Summary

Extracts a message (text or file) from the specified bitmap, if the bitmap has an embedded message. The information of the extracted message is specified by the pAddMesgInfo parameter.

Syntax

#include "l_bitmap.h"

L_LTIMGEFX_API L_INT L_ExtractMessageFromBitmap(pBitmap, pAddMesgInfo, uFlags)

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle referencing the destination bitmap. This is the bitmap from which the function extracts the message.

pADDMESGINFO pAddMesgInfo

Pointer to an ADDMESGINFO structure that contains information about the extracted message.

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

This function is used to extract the message that was added to the bitmap by the function L_AddMessageToBitmap.

Before calling this function, you must declare a variable of data type ADDMESGINFO. Set the pPassword, pStart, pDirectory members of the structure using the same information used for these members when the message was added. You can then pass the address of this structure in the pAddMesgInfo parameter, which this function will update with the extracted message.

This function can extract a message from any type of lossless image format 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-bit images, and 8- and 16-bit grayscale images.

Support for 16-bit grayscale and 48-bit color images is available in the Document/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.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

This example loads a bitmap that has an embedded message and extracts the message from it.

L_INT ExtractMessageFromBitmapExample(L_VOID) 
{ 
   BITMAPHANDLE pBitmap; 
   pADDMESGINFO pAddMesgInfo; 
   L_INT nRet; 
   L_TCHAR szBuf[200]; 
 
   pAddMesgInfo = (pADDMESGINFO)GlobalAllocPtr(GHND, sizeof(ADDMESGINFO)); 
   if (!pAddMesgInfo) 
      return ERROR_NO_MEMORY; 
 
   pAddMesgInfo->uStructSize = sizeof(ADDMESGINFO); 
 
   /* Load the bitmap, using the bits per pixel used for the file */ 
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("IMAGE1.CMP")), &pBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   memset(pAddMesgInfo, 0, sizeof(ADDMESGINFO)); 
 
   /*Extract the message from the image in the default position and with the default password */ 
   nRet = L_ExtractMessageFromBitmap(&pBitmap, pAddMesgInfo, 0); 
 
   /*Determine whether the extracted message is text or file */ 
   if (nRet == SUCCESS) 
   { 
      if (pAddMesgInfo->pStrMsg != NULL) 
      { 
         wsprintf(szBuf, TEXT("Extracted Message: %s\n"), pAddMesgInfo->pStrMsg); 
         _tprintf(_T("%s"), szBuf); 
 
      } 
      else if (pAddMesgInfo->pFileName != NULL) 
      { 
         wsprintf(szBuf, TEXT("Extracted File: %s\n"), pAddMesgInfo->pFileName); 
         _tprintf(_T("%s"), szBuf); 
      } 
      else 
         printf("Error: There is no Message!\n"); 
   } 
   else 
      printf("Error: No message!\n"); 
 
   /*Free the temporary buffers. */ 
   if (pAddMesgInfo->pStrMsg) 
      GlobalFreePtr(pAddMesgInfo->pStrMsg); 
 
   if (pAddMesgInfo->pFileName) 
      GlobalFreePtr(pAddMesgInfo->pFileName); 
 
   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 22.0.2023.7.11
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 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.