LMemoryFile::ReadComment

#include "ltwrappr.h"

virtual L_INT LMemoryFile::ReadComment(LMemoryBuffer, pLCommentBuffer, uType, pLoadFileOption=NULL)

LBuffer& LMemoryBuffer;

/* an LBuffer object */

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

See Also

Functions:

LFile::ReadCommentOffset, Class Members

Topics:

Raster Image Functions: Input and Output

 

Loading and Saving Images

Example

L_VOID TestReadCommentMem()
{
   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(TEXT("1.tif")) ;

   LeadFile.LoadBitmap() ;

   LeadMemFile.SetBitmap(&LeadBitmap) ;
   LeadMemFile.SaveBitmap(&LeadMemBuffer,FILE_LEAD,24,QS) ;

   // 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 ;
   }

   LeadCommBuffer.Reallocate((L_INT32)CommentLength);

   // Get the actual comment from the file
   LeadMemFile.ReadComment ( LeadMemBuffer, &LeadCommBuffer, CMNT_SZDATETIME);

   // 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() ;
}