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
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.

See Also

Functions:

LFile::ReadCommentOffset, Class Members

Topics:

Raster Image Functions: Input and Output

 

Loading and Saving Images

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; 
   LFileSettings fileSettings; 
   L_CHAR *pTextToSet = "Susie, the artist"; 
   LeadFile.SetBitmap(&LeadBitmap) ; 
   LeadFile.SetFileName(MAKE_IMAGE_PATH(TEXT("clean.tif"))) ; 
   nRet = LeadFile.Load() ; 
   if(nRet != SUCCESS) 
      return nRet; 
   LeadMemFile.SetBitmap(&LeadBitmap) ; 
   nRet = fileSettings.SetComment(CMNT_SZARTIST, (L_UCHAR *)pTextToSet, (L_INT) (strlen(pTextToSet) + 1)); 
   if(nRet < 1) 
      return nRet; 
   nRet =LeadMemFile.Save(&LeadMemBuffer,FILE_TIF,8,NULL) ; 
   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_SZARTIST, 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_SZARTIST); 
   if(nRet < 0) 
      return nRet; 
   // Show the comment that was saved in the file 
   wsprintf (szMessage, TEXT("ARTIST:\n %hs"), LeadCommBuffer.Lock()); 
   MessageBox (NULL, szMessage, TEXT("ARTIST"), MB_OK); 
   LeadCommBuffer.Unlock() ; 
   return SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C++ Class Library Help