Gets a single comment, a group of comments or several groups of comments from a file.
#include "ltwrappr.h"
virtual L_INT LFile::ReadComment(uType, pLBuffer, pLoadFileOption=NULL)
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 listed below. For more information concerning FlashPix file comments, see FlashPix File Comments.
Pointer to the buffer object that will hold all the comments.
Pointer to optional extended load options. Pass NULL to use the default load options.
Value | Meaning |
---|---|
>=0 | Length of the comment field. |
< 0 | An error occurred. Refer to Return Codes. |
The basic order of function calls to retrieve comments is as follows:
To write comments to a file, all the comments you wish to add to a new file must be set. LFileSettings::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 LFile::SaveFile or LFile::Save when creating a new file. If you wish to change a comment in an existing file, use LFile::WriteComment.
Win32, x64.
This example demonstrates all of the functions related to comments for TIFF files.
It clears all comments, sets a new comment, gets the comment from memory,
saves a file with the comment, then gets the comment from the file.
L_INT LFile__ReadCommentExample()
{
L_INT nRet;
L_INT CommentLength;
LBitmap LeadBitmap;
LFileSettings fileSettings;
HGLOBAL hTextToGet;
L_CHAR *pTextToSet = "Susie, the artist";
L_CHAR *pTextToGet;
L_TCHAR message[200];
//Set the comment
nRet = fileSettings.SetComment(CMNT_SZARTIST, (L_UCHAR *)pTextToSet, (L_INT) (strlen(pTextToSet) + 1));
if(nRet < 0)
return nRet;
//Get the length of a comment
CommentLength = fileSettings.GetComment(CMNT_SZARTIST, NULL, 0);
//Allocate and lock a zero-filled buffer for the comment
hTextToGet = GlobalAlloc(GPTR, CommentLength);
pTextToGet = (L_CHAR *)GlobalLock(hTextToGet);
//Get the actual comment
fileSettings.GetComment(CMNT_SZARTIST, (L_UCHAR *)pTextToGet, CommentLength);
//Show the comment that will be saved
wsprintf(message,TEXT(" %hs"),pTextToGet);
::MessageBox(NULL, message, TEXT("Saving Artist Comment"), MB_OK);
// Free memory
GlobalUnlock(hTextToGet);
GlobalFree(hTextToGet);
//Load, and then save the image with the new comment
LeadBitmap.SetFileName(MAKE_IMAGE_PATH(TEXT("clean.tif")));
nRet = LeadBitmap.Load();
if(nRet != SUCCESS)
return nRet;
LeadBitmap.SetFileName(MAKE_IMAGE_PATH(TEXT("output.tif")));
nRet = LeadBitmap.Save(FILE_TIF, 8, 0, NULL, NULL);
if(nRet != SUCCESS)
return nRet;
//Get the length of a comment in the file
CommentLength = LeadBitmap.File()->ReadComment(CMNT_SZARTIST, NULL);
//Get the actual comment from the file
LBuffer LeadBuffer(CommentLength);
nRet = LeadBitmap.File()->ReadComment(CMNT_SZARTIST, &LeadBuffer);
if(nRet < 1)
return nRet;
//Show the comment that was saved in the file
wsprintf(message,TEXT(" %hs"),LeadBuffer.Lock());
::MessageBox (NULL, message, TEXT("Artist comment"), MB_OK);
LeadBuffer.Unlock();
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document