Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Monday, March 17, 2008 12:17:58 AM(UTC)
thenarsis

Groups: Registered
Posts: 13


This is the Example by leadtools document classlibrary.
This example gets the CMNT_SZDATETIME comment from a TIFF file in memory

 L_INT ReadFileCommentMemoryExample(L_UCHAR * pBuf, L_SIZE_T lFileSize)
{
   L_INT nRet;
   L_TCHAR szMessage[80];  /* MessageBox string                */
   L_CHAR * 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 *)GlobalLock( hTextToGet );
   /* Get the actual comment from the file */
   nRet = L_ReadFileCommentMemory (pBuf, CMNT_SZDATETIME, (L_UCHAR *) pTextToGet, CommentLength, lFileSize, NULL);
   /* Show the comment that was saved in the file */
   L_TCHAR buf[100];
   size_t conv;
   mbstowcs_s(&conv, buf, 100, pTextToGet, min(nRet,100));
   wsprintf (szMessage, TEXT("CMNT_SZDATETIME:\n %s"), buf);
   MessageBox (NULL, szMessage, TEXT("CMNT_SZARTIST"), MB_OK);
   /* Free memory */
   GlobalUnlock(hTextToGet);
   GlobalFree(hTextToGet);
   return SUCCESS;
}

Quetion 1
    How to set this value(L_UCHAR * pBuf, L_SIZE_T lFileSize)??
Quetion 2
    How to get the datetime value?

 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Monday, March 17, 2008 7:28:13 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)


Hello,

Do
you need to read comments from an EXIF file, and the entire EXIF file is stored in a memory buffer?




This is what the L_ReadFileCommentMemory function does.


If
you have a file in memory (for example using L_SaveFileBuffer) this function
will return a pointer to a memory buffer which is the pBuf variable and a size of the memory buffer which is lFileSize.




About
the second question, the value returned by the third parameter in the L_ReadFileCommentMemory function, in this case the pTextToGet variable.


About
the Date Time comment the type of CMNT_SZDATETIME is L_UINT so the pTextToGet
variable will contain: Date and time (YYYY:MM:DD HH:MM:SS). The field length is 20, counting the NULL terminator.

 
#3 Posted : Tuesday, March 18, 2008 8:55:37 PM(UTC)
thenarsis

Groups: Registered
Posts: 13


It's example from Leadtools help , but I can't get the datetime in Exif file format.
I can't understand...
Please, check the this example source, and then reply your answer.
How to get datetime?

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(TEXT("C:\\Program Files\\LEAD Technologies, Inc\\LEADTOOLS 15.0\\Images\\1.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;
}

 
#4 Posted : Wednesday, March 19, 2008 5:42:07 AM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

Was thanked: 1 time(s) in 1 post(s)

Hello,

The comment itself is a string value. The code below shows how to extract it and display it in a message box
+---------+
L_INT nRet;
LBitmapBase BitmapBase;
LFile MyFile;
LBuffer LeadBuffer(20);
L_TCHAR message[200];


LBase::LoadLibraries(LT_ALL_LEADLIB);

MyFile.SetBitmap(&BitmapBase);
MyFile.SetFileName(TEXT("c:\\Exif.JPG"));
nRet = MyFile.LoadFile(24, ORDER_RGB, LOADFILE_ALLOCATE | LOADFILE_STORE);

nRet = MyFile.ReadComment(CMNT_SZDATETIME, &LeadBuffer);

wsprintf(message,TEXT(" %hs"),LeadBuffer.Lock());
::MessageBox (NULL, message, TEXT("Artist comment"), MB_OK);
LeadBuffer.Unlock()
+---------+

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#5 Posted : Wednesday, March 19, 2008 2:38:08 PM(UTC)
thenarsis

Groups: Registered
Posts: 13


This sample source return value 0.......................-_-;;;;

What is problem??

 
#6 Posted : Wednesday, March 19, 2008 2:41:30 PM(UTC)
thenarsis

Groups: Registered
Posts: 13


nRet = LeadFile.ReadComment(CMNT_SZDATETIME, &LeadBuffer);
nRet is 0

 LFile                  LeadFile;
 L_INT               CommentLength;
 L_INT               nRet;
 L_TCHAR         message[200];
 L_TCHAR         szMessage[200];
 LBitmapBase      LeadBitmap;
 LBuffer               LeadBuffer(20);

 LeadFile.SetBitmap(&LeadBitmap) ;
 LeadFile.SetFileName((LPWSTR)pszFilename);
 nRet = LeadFile.LoadFile(24, ORDER_RGB, LOADFILE_ALLOCATE | LOADFILE_STORE);
 if (nRet != SUCCESS)
 {
     AfxMessageBox(TEXT("LoadFile"));
 }
 nRet = LeadFile.ReadComment(CMNT_SZDATETIME, &LeadBuffer);
 if (nRet != SUCCESS)
 {
     TCHAR temp[128];
     wsprintf(temp, TEXT("ReadComment : [%d]"), nRet);
     AfxMessageBox(temp);
 }
 wsprintf(message,TEXT(" %hs"), LeadBuffer.Lock());
 ::MessageBox (NULL, message, TEXT("DateTime"), MB_OK);
 LeadBuffer.Unlock();

 
#7 Posted : Friday, March 21, 2008 11:31:39 AM(UTC)

jigar  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

What version of the toolkit do you have?  I tested your code above and I was able to get a valid value for ReadComment().

My versions:

       ltfil15u.dll      15.0.1.1
       lftif15u.dll      15.0.1.0
 
#8 Posted : Friday, March 21, 2008 9:56:09 PM(UTC)
thenarsis

Groups: Registered
Posts: 13


My versions :

ltfile15u.dll      15.0.0.15
lftif15u.dll        15.0.0.5
ltkrn15u.dll      15.0.0.8
ltwvc215u.dll   15.0.0.7

what's the problem???/

 
#9 Posted : Sunday, March 23, 2008 2:42:27 AM(UTC)

Adam Boulad  
Guest

Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)


Please send your LEADTOOLS v15 serial number to support@leadtools.com
and ask for the latest patches and mention this post. If you don't have a serial number, ask for the latest evaluation patches.

 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.161 seconds.