L_GetFileCommentSize

#include "l_bitmap.h"

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

L_TCHAR L_FAR * pszFile;

/* file name */

L_UINT uType;

/* type of comment */

L_UINT L_FAR * 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. 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.

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

Windows 95 / 98 / Me, Windows 2000 / XP, Windows CE.

See Also

Functions:

L_ReadFileComment,

 

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

For the following examples:

L_INT I;
L_TCHAR szTemp[80];
L_UINT32 uLength;
L_TCHAR szMessage[80];
HGLOBAL hTextToGet;
L_UCHAR L_FAR *pTextToGet;
L_FLOAT L_FAR *pFloat;
L_CHAR L_FAR *pString;

L_TCHAR szBuf[80];
L_INT nStatus;
FPXCOMMENT_HEADER_ARRAY L_FAR *pArray;
FPXCOMMENT_HEADER_ELEMENT L_FAR *pElement;

//Read one comment - data type: FlashPixFloatArray

nStatus = L_GetFileCommentSize(TEXT("TEST.FPX"), CMNT_FPXBRIGHTNESSVALUE,
                                    &uLength, NULL);
hTextToGet = GlobalAlloc(GPTR, uLength);
pTextToGet = (L_UCHAR L_FAR *)GlobalLock(hTextToGet);
nStatus = L_ReadFileComment(TEXT("TEST.FPX"), CMNT_FPXBRIGHTNESSVALUE, pTextToGet, uLength, NULL);
pArray = (FPXCOMMENT_HEADER_ARRAY L_FAR *)pTextToGet;
if(pArray != NULL)
{
 szMessage[0] = '\0';
 pFloat = (L_FLOAT L_FAR *)(pArray + 1);
 for(I = 0; I < (L_INT)pArray->elements; I++)
 {
  wsprintf(szTemp, TEXT("%5.2f"), pFloat[I]);
  lstrcat(szMessage, szTemp);
 }
 MessageBox(NULL, szMessage, TEXT("Brightness Values"), MB_OK);
}
GlobalFree(hTextToGet);

//Read one comment - data type: FlashPixString

L_GetFileCommentSize(TEXT("TEST.FPX"), CMNT_FPXTITLE, &uLength, NULL);
hTextToGet = GlobalAlloc(GPTR, uLength);
pTextToGet = (L_UCHAR L_FAR *)GlobalLock(hTextToGet);
L_ReadFileComment(TEXT("TEST.FPX"), CMNT_FPXTITLE, pTextToGet, uLength, NULL);
pArray = (FPXCOMMENT_HEADER_ARRAY L_FAR *)pTextToGet;
if(pArray != NULL)
{
 pString = (L_CHAR L_FAR *)(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

nStatus = L_GetFileCommentSize(TEXT("TEST.FPX"), CMNT_FPXEXPOSURETIME, &uLength, NULL);
hTextToGet = GlobalAlloc(GPTR, uLength);
pTextToGet = (L_UCHAR L_FAR *)GlobalLock(hTextToGet);

nStatus = L_ReadFileComment(TEXT("TEST.FPX"), CMNT_FPXEXPOSURETIME, pTextToGet, uLength, NULL);
pElement = (FPXCOMMENT_HEADER_ELEMENT L_FAR *)pTextToGet;
if(pElement != NULL)
{
 pFloat = (L_FLOAT L_FAR *)(pElement + 1);
 wsprintf(szMessage, TEXT("%f"), *pFloat);
 MessageBox(NULL, szMessage, TEXT("Exposure Time"), MB_OK);
}
GlobalFree(hTextToGet);

See also the examples listed under L_ReadFileCommentExt.