L_GetFileCommentSize

#include "l_bitmap.h"

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

L_TCHAR* pszFile;

/* file name */

L_UINT uType;

/* type of comment */

L_UINT* uLength;

/* pointer to the size, in bytes, of the comment field */

pLOADFILEOPTION pLoadOptions;

/* pointer to optional extended load options */

Gets the size, in bytes, of the comments.

Parameter

Description

pszFile

Character string containing the FlashPix file name.

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,see FlashPix File Comments.

uLength

Pointer to the size of the comments requested.

pLoadOptions

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

Returns

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:

 

Get the size of the comments with L_GetFileCommentSize

 

Allocate a buffer of a corresponding size.

 

Read the comments with L_ReadFileCommentExt or L_ReadFileComment.

 

Free the buffer

Required DLLs and Libraries

LTFIL
File format DLLs

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Win32, x64, Mobile.

See Also

Functions:

L_ReadFileComment, L_ReadFileComments

 

L_SetComment,

 

L_ReadFileCommentExt

 

L_WriteFileCommentExt

Topics:

Raster Image Functions: Maintaining File Comments,

 

Loading and Saving Images

For a list of functions that utilize the LOADFILEOPTION or SAVEFILEOPTION structures, refer to Functions Utilizing the LOADFILEOPTION or SAVEFILEOPTION structures.

Example

See also the examples listed under 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;
}