L_GetFileCommentSize

Summary

Gets the size, in bytes, of the comments.

Syntax

#include "l_bitmap.h"

L_LTFIL_API L_INT L_GetFileCommentSize(pszFile, uType, uLength, pLoadOptions)

Parameters

L_TCHAR* pszFile

Character string containing the FlashPix file name.

L_UINT uType

The type of comment. Refer to Types of File Comments.

A group of comments may be obtained such as CMNT_FPXSUMMARYINFORMATION, or more than one group of comments may be retrieved by using OR as in CMNT_FPXSUMMARYINFORMATION | CMNT_FPXFILESOURCEGROUP, or all comments may be obtained by using CMNT_ALL. See "Example" under L_ReadFileCommentExt.

For more information concerning FlashPix file comments, refer to FlashPix File Comments.

L_UINT* uLength

Pointer to the size of the comments requested.

pLOADFILEOPTION pLoadOptions

Pointer to optional extended load options. Pass NULL to use the default load options.

Returns

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

Comments

Presently this function only works with FlashPix files.

To write comments to a file, all the comments you wish to add to a file must be set using L_SetComment. The L_SetComment function sets each comment individually, but it does not save the comments to the file, it prepares the values for the next save. Once all comments are set, the comments are saved using any function which saves files, such as L_SaveFile or L_SaveBitmap when creating a new file. If you wish to change a comment in an existing file, use L_WriteFileCommentExt.

The basic order of function calls for reading comments is as follows:

  1. Get the size of the comments with L_GetFileCommentSize
  2. Allocate a buffer of a corresponding size.
  3. Read the comments with L_ReadFileCommentExt or L_ReadFileComment.
  4. Free the buffer.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

For an example, refer to L_ReadFileCommentExt.

typedef struct _FPXCOMMENT_HEADER_ELEMENT 
{ 
   L_UINT32 size; 
   L_UINT32 type; 
} FPXCOMMENT_HEADER_ELEMENT; 
 
typedef struct _FPXCOMMENT_HEADER_ARRAY 
{ 
   L_UINT32 size; 
   L_UINT32 type; 
   L_UINT32 elements; 
}FPXCOMMENT_HEADER_ARRAY; 
 
L_INT GetFileCommentSizeExample(L_VOID) 
{ 
   L_INT nRet; 
   L_INT I; 
   L_TCHAR  szTemp[80]; 
   L_UINT32 uLength; 
   L_TCHAR  szMessage[80]; 
   HGLOBAL  hTextToGet; 
   L_UCHAR  *pTextToGet; 
   L_FLOAT  *pFloat; 
   L_CHAR   *pString; 
 
   L_TCHAR szBuf[80]; 
   FPXCOMMENT_HEADER_ARRAY *pArray; 
   FPXCOMMENT_HEADER_ELEMENT *pElement; 
 
   //Read one comment - data type: FlashPixFloatArray 
 
   nRet = L_GetFileCommentSize(MAKE_IMAGE_PATH(TEXT("IMAGE1.FPX")), CMNT_FPXBRIGHTNESSVALUE, &uLength, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
    
   if( uLength ) 
   { 
      hTextToGet = GlobalAlloc(GPTR, uLength); 
      pTextToGet = (L_UCHAR  *)GlobalLock(hTextToGet); 
      nRet =L_ReadFileComment(MAKE_IMAGE_PATH(TEXT("IMAGE1.FPX")), CMNT_FPXBRIGHTNESSVALUE, pTextToGet, uLength, NULL); 
      if(nRet !=SUCCESS) 
         return nRet; 
      pArray = (FPXCOMMENT_HEADER_ARRAY  *)pTextToGet; 
      if(pArray != NULL) 
      { 
       szMessage[0] = '\0'; 
       pFloat = (L_FLOAT  *)(pArray + 1); 
       for(I = 0; I < (L_INT)pArray->elements; I++) 
       { 
       _stprintf_s(szTemp,80, TEXT("%5.2f"), pFloat[I]); 
        lstrcat(szMessage, szTemp); 
       } 
       MessageBox(NULL, szMessage, TEXT("Brightness Values"), MB_OK); 
      } 
      GlobalFree(hTextToGet); 
   } 
 
   //Read one comment - data type: FlashPixString 
 
   nRet = L_GetFileCommentSize(MAKE_IMAGE_PATH(TEXT("TEST.FPX")), CMNT_FPXTITLE, &uLength, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
    
   if( uLength ) 
   { 
      hTextToGet = GlobalAlloc(GPTR, uLength); 
      pTextToGet = (L_UCHAR  *)GlobalLock(hTextToGet); 
      nRet = L_ReadFileComment(MAKE_IMAGE_PATH(TEXT("TEST.FPX")), CMNT_FPXTITLE, pTextToGet, uLength, NULL); 
      if(nRet != SUCCESS) 
         return nRet; 
      pArray = (FPXCOMMENT_HEADER_ARRAY  *)pTextToGet; 
      if(pArray != NULL) 
      { 
       pString = (L_CHAR  *)(pArray + 1);   /* points to first position after header*/ 
 
       wsprintf (szBuf, TEXT("%hs"), pString); 
 
       MessageBox (NULL, szBuf, TEXT("Title"), MB_OK); 
      } 
      GlobalFree(hTextToGet); 
   } 
 
   //Read one comment - data type: FlashPixFloat 
 
   nRet =L_GetFileCommentSize(MAKE_IMAGE_PATH(TEXT("TEST.FPX")), CMNT_FPXEXPOSURETIME, &uLength, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   if( uLength ) 
   { 
      hTextToGet = GlobalAlloc(GPTR, uLength); 
      pTextToGet = (L_UCHAR  *)GlobalLock(hTextToGet); 
 
      nRet =L_ReadFileComment(MAKE_IMAGE_PATH(TEXT("TEST.FPX")), CMNT_FPXEXPOSURETIME, pTextToGet, uLength, NULL); 
      if(nRet !=SUCCESS) 
         return nRet; 
      pElement = (FPXCOMMENT_HEADER_ELEMENT  *)pTextToGet; 
      if(pElement != NULL) 
      { 
       pFloat = (L_FLOAT  *)(pElement + 1); 
       _stprintf_s(szMessage,80, TEXT("%f"), *pFloat); 
       MessageBox(NULL, szMessage, TEXT("Exposure Time"), MB_OK); 
      } 
      GlobalFree(hTextToGet); 
   } 
    
   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.