L_ReadFileCommentMemory
#include "l_bitmap.h"
L_INT EXT_FUNCTION L_ReadFileCommentMemory(pBuffer, uType, pComment, uLength, nBufferSize, pLoadOptions)
/* pointer to the file in memory */ | |
L_UINT uType; |
/* type of comment */ |
/* pointer to your buffer for the comment field */ | |
L_UINT uLength; |
/* size of your buffer for the comment field */ |
L_INT32 nBufferSize; |
/* size of the file in memory (in bytes) */ |
pLOADFILEOPTION pLoadOptions; |
/* pointer to optional extended load options */ |
Gets a comment field from a file in memory.
Parameter |
Description |
pBuffer |
Pointer to the file in memory. |
uType |
The type of comment. Refer to Types of File Comments. |
pComment |
Pointer to your buffer that will hold the comment field, including the terminating NULL. You can pass NULL if you only want to get the length of the field (the return value). |
uLength |
The size of your buffer that will hold the comment field. |
nBufferSize |
Size of the file in memory (in bytes). |
pLoadOptions |
Pointer to optional extended load options. Pass NULL to use the default load options. |
Returns
>=0 |
Length of the comment field. |
< 0 |
An error occurred. An error occurred. Refer to Return Codes. |
Comments
Some file formats can contain comments, and some cannot, and each file format has its own set of comment types. When you save a file, the comments, which LEADTOOLS maintains in a global array, are saved in the file. The index into the array (specified using a constant) determines the type of comment, as described in Types of File Comments.
Before saving a file, you use the L_SetComment function to specify the comments to be saved.
The L_ReadFileCommentMemory function lets you read comments that are already saved in a file in memory. For more information refer to the L_SetComment function.
Note: |
More options are available in the LOADFILEOPTION structure. |
Note: |
This function does not support Kodak FlashPix files. |
Required DLLs and Libraries
LTFIL 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
For a list of functions that utilize the LOADFILEOPTION or SAVEFILEOPTION structures, refer to Functions Utilizing the LOADFILEOPTION or SAVEFILEOPTION structures.
Example
/* This example gets the CMNT_SZDATETIME comment from a TIFF file in memory */
void ReadComment ( L_CHAR L_HUGE *pBuf, L_INT32 lFileSize )
{
/* pBuf is the buffer holding the image file */
L_TCHAR szMessage[80]; /* MessageBox string */
L_CHAR L_FAR * pTextToGet; /* Comment string that we will get */
HGLOBAL hTextToGet; /* Handle for memory management */
L_INT CommentLength; /* Length of the comment string that we will get */
/* Use the return value to get the length of a comment in the file */
CommentLength = L_ReadFileCommentMemory (pBuf, CMNT_SZDATETIME, NULL, 0, lFileSize, NULL);
/* Allocate and lock a zero-filled buffer for the comment */
hTextToGet = GlobalAlloc(GPTR, CommentLength);
pTextToGet = (L_CHAR L_FAR *)GlobalLock( hTextToGet );
/* Get the actual comment from the file */
L_ReadFileCommentMemory ( pBuf,
CMNT_SZDATETIME,
(L_UCHAR L_FAR *) pTextToGet,
CommentLength,
lFileSize, NULL );
/* Show the comment that was saved in the file */
wsprintf (szMessage, TEXT("DATE_TIME:\n %hs"), pTextToGet);
MessageBox (NULL, szMessage, TEXT("Date_Time"), MB_OK);
/* Free memory */
GlobalUnlock(hTextToGet);
GlobalFree(hTextToGet);
}