Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
LMemoryFile::ReadComment
#include "ltwrappr.h"
virtual L_INT LMemoryFile::ReadComment(LMemoryBuffer, pLCommentBuffer, uType, pLoadFileOption=NULL)
LBuffer& LMemoryBuffer; |
/* an LBuffer object */ |
LBuffer * pLCommentBuffer; |
/* pointer to an LBuffer object */ |
L_UINT uType; |
/* type of comment */ |
pLOADFILEOPTION pLoadFileOption; |
/* pointer to optional extended load options */ |
Gets a comment field from a file in memory.
Parameter |
Description |
LMemoryBuffer |
A LEAD LBuffer object that contains the file in memory. |
pLCommentBuffer |
A LEAD LBuffer object to be updated with 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). |
uType |
The type of comment. Refer to Types of File Comments. |
pLoadFileOption |
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. 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 LFileSettings::SetComment function to specify the comments to be saved.
The LMemoryFile::ReadComment function lets you read comments that are already saved in a file in memory. For more information refer to the LFileSettings::SetComment function.
Note: More options are available in the LOADFILEOPTION structure.
Note: This function does not support Kodak FlashPix files.
The LMemoryBuffer parameter is passed by reference, and is a required parameter.
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. |
Win32, x64.
See Also
Functions: |
|
Topics: |
|
|
Example
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName L_INT LMemoryFile__ReadCommentExample() { L_INT nRet; L_TCHAR szMessage[80]; // MessageBox string L_INT CommentLength; // Length of the comment string that we will get LMemoryFile LeadMemFile ; LBuffer LeadMemBuffer ; LBuffer LeadCommBuffer ; LFile LeadFile ; LBitmapBase LeadBitmap; LeadFile.SetBitmap(&LeadBitmap) ; LeadFile.SetFileName(MAKE_IMAGE_PATH(TEXT("clean.tif"))) ; nRet = LeadFile.Load() ; if(nRet != SUCCESS) return nRet; LeadMemFile.SetBitmap(&LeadBitmap) ; nRet =LeadMemFile.Save(&LeadMemBuffer,FILE_LEAD,24,QS) ; if(nRet !=SUCCESS) return nRet; // Use the return value to get the length of a comment in the file CommentLength = LeadMemFile.ReadComment (LeadMemBuffer, NULL, CMNT_SZDATETIME, NULL); if (CommentLength < 0) { MessageBox(NULL,TEXT("File has not comment ..."), TEXT("Read Memory Comment"),MB_OK) ; return CommentLength; } nRet =LeadCommBuffer.Reallocate((L_INT32)CommentLength); if(nRet !=SUCCESS) return nRet; // Get the actual comment from the file nRet =LeadMemFile.ReadComment ( LeadMemBuffer, &LeadCommBuffer, CMNT_SZDATETIME); if(nRet < 0) return nRet; // Show the comment that was saved in the file wsprintf (szMessage, TEXT("DATE_TIME:\n %hs"), LeadCommBuffer.Lock()); MessageBox (NULL, szMessage, TEXT("Date_Time"), MB_OK); LeadCommBuffer.Unlock() ; return SUCCESS; }