L_ReadFileCommentExt

#include "l_bitmap.h"

L_LTFIL_API L_INT L_ReadFileCommentExt (pszFile, uType, pComments, pBuffer, uLength, pLoadOptions)

Gets a single comment, a group of comments or several groups of comments from a file.

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 listed below. For more information concerning FlashPix file comments, see FlashPix File Comments.

pFILECOMMENTS pComments

Pointer to a structure which contains a data value indicating the number of comments stored, a pointer to an array of pointers which in turn point to the individual Comments, and a pointer to an array of integers which indicate the size of each Comment stored.

L_UCHAR* pBuffer

Pointer to the buffer that will hold all the comments

L_UINT* uLength

Pointer to the size of the buffer that will hold all the comments.

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 format files.

The basic order of function calls to retrieve 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.
  4. Free the buffer.

To write comments to a file, all the comments you wish to add to a new file must be set. L_SetComment 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.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

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 ReadFileCommentExtExample(L_VOID) 
{ 
   L_INT nRet; 
   L_UINT32 uLength = 0; 
   L_TCHAR szMessage[80]; 
   L_UCHAR   *pTextToGet; 
   L_FLOAT  *pFloat; 
   L_UINT32 *pLong; 
   L_TCHAR   *pString; 
   FPXCOMMENT_HEADER_ARRAY *pArray; 
   FPXCOMMENT_HEADER_ELEMENT *pElement; 
   FILECOMMENTS FileComments; 
   L_UCHAR  *pPointer [CMNT_LAST + 1]; 
   L_UINT uSize[CMNT_LAST + 1]; 
   L_TCHAR szFileName[256] = MAKE_IMAGE_PATH(TEXT("IMAGE1.FPX")); 
 
   //Read one group of comments: 
   /* Determine the size, in bytes, of the desired group of comments. */ 
   nRet = L_GetFileCommentSize(szFileName, CMNT_FPXTITLE, &uLength, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   if(uLength == 0) 
      return ERROR_INV_PARAMETER; 
 
   /* Allocate a buffer based on the size of the comments obtained by 
      nRet = L_GetFileCommentSize and stored in uLength. */ 
   pTextToGet = (L_UCHAR *)malloc(uLength); 
 
   /* Initialize the FileComments structure. */ 
   FileComments.count = CMNT_LAST + 1; 
   FileComments.pointer = pPointer; 
   FileComments.size = uSize; 
 
   /* Read the group of comments into the buffer. */ 
   nRet = L_ReadFileCommentExt (szFileName, CMNT_FPXTITLE, &FileComments, pTextToGet, &uLength, NULL); 
   if(nRet != SUCCESS) 
   { 
      free(pTextToGet); 
      return nRet; 
   } 
 
   /* Extract the desired individual comments from within the group */ 
   pArray = (FPXCOMMENT_HEADER_ARRAY *)pPointer [CMNT_FPXTITLE]; 
   pElement = (FPXCOMMENT_HEADER_ELEMENT *)pPointer [CMNT_FPXSECURITY]; 
 
   /* Test to be sure the comments exist. If they exist, print them.*/ 
   if((pArray != NULL)&&(pElement != NULL)) 
   { 
    pString = (L_TCHAR  *)(pArray + 1); 
    pLong = (L_UINT32  *)(pElement + 1); 
    //wsprintf(szMessage, TEXT("%hs-%ul"), pString, *pLong); 
    wsprintf(szMessage, TEXT("%ul"), *pLong); 
    MessageBox(NULL, szMessage, TEXT("Title & Security"), MB_OK); 
   } 
 
   /* Free the buffer. */ 
   free(pTextToGet); 
 
   //Read groups of comments: 
   uLength = 0; 
   nRet = L_GetFileCommentSize(szFileName, CMNT_FPXSUMMARYINFORMATION |  
                        CMNT_FPXINTELLECTUALPROPERTYGROUP, &uLength, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   if(uLength != 0) 
   { 
      pTextToGet = (L_UCHAR  *)malloc(uLength); 
      FileComments.count = CMNT_LAST + 1; 
      FileComments.pointer = pPointer; 
      FileComments.size = uSize; 
      nRet = L_ReadFileCommentExt(szFileName, CMNT_FPXSUMMARYINFORMATION | CMNT_FPXINTELLECTUALPROPERTYGROUP, &FileComments, pTextToGet, &uLength, NULL); 
      if(nRet != SUCCESS) 
         return nRet; 
      pArray = (FPXCOMMENT_HEADER_ARRAY *)pPointer[CMNT_FPXTITLE]; 
      pElement = (FPXCOMMENT_HEADER_ELEMENT *) pPointer[CMNT_FPXEXPOSURETIME]; 
      if((pArray != NULL)&&(pElement != NULL)) 
      { 
         pString = (L_TCHAR  *)(pArray + 1); 
         pFloat = (L_FLOAT  *)(pElement + 1); 
         _stprintf_s(szMessage,80, TEXT("%hs-%f"), pString, *pFloat); 
         MessageBox(NULL, szMessage, TEXT("Title & Exposure Time"), MB_OK); 
      } 
 
      free(pTextToGet); 
 
      //Read all comments: 
      uLength = 0; 
      nRet = L_GetFileCommentSize(MAKE_IMAGE_PATH(TEXT("IMAGE1.FPX")), CMNT_ALL, &uLength, NULL); 
      if(nRet != SUCCESS) 
         return nRet; 
      if(uLength != 0) 
      { 
         pTextToGet = (L_UCHAR *)malloc(uLength); 
         FileComments.count = CMNT_LAST + 1; 
         FileComments.pointer = pPointer; 
         FileComments.size = uSize; 
         nRet = L_ReadFileCommentExt(szFileName, CMNT_ALL, &FileComments, pTextToGet, &uLength, NULL); 
         if(nRet != SUCCESS) 
         { 
            free(pTextToGet); 
            return nRet; 
         } 
         pArray = (FPXCOMMENT_HEADER_ARRAY *)pPointer[CMNT_FPXTITLE]; 
         pElement = (FPXCOMMENT_HEADER_ELEMENT *)pPointer[CMNT_FPXEXPOSURETIME]; 
         if((pArray != NULL)&&(pElement != NULL)) 
         { 
            pString = (L_TCHAR *)(pArray + 1); 
            pFloat =  (L_FLOAT *)(pElement + 1); 
            _stprintf_s(szMessage,80, TEXT("%hs-%f"), pString, *pFloat); 
            MessageBox(NULL, szMessage, TEXT("Title & Exposure Time"), MB_OK); 
         } 
         free(pTextToGet); 
      } 
   } 
   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