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 : Sunday, November 25, 2007 6:05:25 AM(UTC)
MikelFinch

Groups: Registered
Posts: 3


I have a DLL that uses LeadTools 14.5.  In the DLL I use both the VCL and C++ Class Wrappers.  I can use all of the functions in the VCL without any problems.  However, when I start making the C++ Class Wrapper functions I start to get errors.  I have seen both LMemoryFile::GetInfo() and LMemoryFile::LoadMemory() return a -1041, meaning LTFIL14 is not loaded.  However, if I look at the loaded DLLs LTFIL14 is in my application DLL list.

These functions will not start working until I do a LBase::LoadLibraries() call.  I want to load as few DLLs as possible and the following will work:

#define  MY_LT_ALL_LEADLIB                   \
         LT_KRN|                          \
         LT_DIS|LT_FIL|LT_IMG|LT_EFX  

...

LBase::LoadLibraries(MY_LT_ALL_LEADLIB);

Has anyone ever seen this behavior before?  I think it is strange that it is telling me a DLL is not loaded when it really is.  If this is required I was going to add LBase::LoadLibraries() when my DLL is loaded and add LBase::UnloadLibraries() when my DLL is unloaded.

Here is my sample code.

....

struct ImageStruct
{
   long uiLibsLoaded;
   LBuffer  imgBuff; // Holds any image data from file.
   ImageStruct()
   {
      uiLibsLoaded = LBase::LoadLibraries(LT_ALL_LEADLIB);
   }
   ~ImageStruct()
   {
      LBase::UnloadLibraries(LT_ALL_LEADLIB);
   }
};

....

int DLLWAY MING_ConvertImageToThumbnail(long *hFrameBuffer,
   long *hThumbBuffer,
   long hErr,
   double dHeight,
   double dWidth)
{
   START_FUNCT_CATCH
   LBitmapBase BitmapBase;
   LMemoryFile ImageData(&BitmapBase);
   LBuffer *frameBuff = &((ImageStruct *)*hFrameBuffer)->imgBuff;
   LBuffer *thumbBuff = &((ImageStruct *)*hThumbBuffer)->imgBuff;
   FILEINFO Info;
   double dAspect, dThumbHeight, dThumbWidth;

   ImageData.GetInfo(*frameBuff, &Info, sizeof(FILEINFO));
   if(ImageData.LoadMemory(*frameBuff) != SUCCESS)
   {
      return MMS_NODATA;
   }  
   // Calculate the thumbnail image dimmention and keep aspect ratio.
   dAspect = (double)Info.Width / (double)Info.Height;
   // Shoot for around 100 X 100, but aspect ratio has the last say.
   dThumbHeight = (double)Info.Height / dHeight;
   dThumbWidth =  (double)Info.Width / dWidth;
   if(dThumbHeight <= dThumbWidth && dThumbHeight)
   {
      dThumbHeight = ceil((double)Info.Height / dThumbHeight);
      dThumbWidth = ceil(dAspect * dThumbHeight);
   }
   else   // Use the iThumbWidth to calc size.
   {
      dThumbWidth = ceil((double)Info.Width / dThumbWidth);
      dThumbHeight = ceil((double)dThumbWidth / dAspect);
   }
   if ( BitmapBase.Size(dThumbWidth, dThumbHeight, SIZE_RESAMPLE) != SUCCESS )
   {
      return MMS_ERROR;
   }
   if(ImageData.SaveBitmap(thumbBuff, FILE_JPEG, 0, 30) != SUCCESS)
   {
      return MMS_ERROR;
   }
   END_FUNCT_CATCH(hErr);
   return MMS_NOERROR;
}

Regards,

Mikel Finch

 

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 : Sunday, November 25, 2007 9:27:56 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

Hello,

The LMemoryFile::GetInfo and LMemoryFile::LoadMemory functions require loading the LTFIL DLL at run-time. Before calling these functions, try to call the LBase::LoadLibraries(LT_FIL) function.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
#3 Posted : Monday, November 26, 2007 6:34:52 AM(UTC)
MikelFinch

Groups: Registered
Posts: 3


Maen,

So I am required to load it even if it is already loaded by the VCL controls?  Loading my DLL will cause the following LeadTools DLLs to load automatically (because I am using the VCL):

LTDIS14N.dll

LTDLGKRN14N.dll

LTEFX14N.dll

LTFIL14N.dll

LTIMG14N.dll

LTKRN14N.dll

LTLST14N.dll

LTWEN14N.dll

So I need to call LBase::LoadLibraries(LT_FIL) even though it is already loaded?

If I add LBase::LoadLibraries(LT_FIL) to the top of my function then it will be called several times.  Is that OK or should I only call LoadLibraries() once, like DLL load.  Also, calling LoadLibraries() doesn't require a call to LBase::LoadLibraries(LT_FIL) at some point?

Regards,

Mikel Finch

 
#4 Posted : Monday, November 26, 2007 10:19:05 PM(UTC)
Maen Hasan

Groups: Registered, Tech Support
Posts: 1,326

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

Hello,

When you call the LBase::LoadLibraries(LT_FIL), it loads the LTFIL DLL at runtime. If the library is already loaded then this function will not load it again.

You need to call the LoadLibraries only one time in your project. There is no need to call it several times. You can load and unload the libraries you need when necessary.

Thanks,
Maen Badwan
LEADTOOLS Technical Support
 
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.138 seconds.