Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Loading txt files - invalid file format
Started by jjwalters at 06-16-2008 6:30. Topic has 4 replies.

Print Search « Previous Thread Next Thread »
  06-16-2008, 6:30
jjwalters is not online. Last active: 7/17/2008 10:20:22 AM jjwalters

Top 500 Posts
Joined on 06-11-2008
Posts 11
Loading txt files - invalid file format
Reply Quote
Hello
I bet I've forgotten to do some basic configuration - but I have searched the LeadTools chm files, Googled extensively, and searched this forum and come up with nothing.
I'm using LeadTools 15 Raster Image Pro - evaluation.

How do I load a .txt (plain non-Unicode ASCII text) file - without getting an Invalid File Format error.
I can't even do a LFile.GetInfo() - get the same error.
My ultimate aim is to render the txt file as a bitmap.

Here's my code
<code>
LBase::LoadLibraries(LT_KRN | LT_FIL); // Does nothing if they are already loaded.

L_TCHAR *filename = "some file name.txt";
LFile LeadFile;
LeadFile.SetFileName(filename);

FILEINFO fileInfo;
ZeroMemory(&fileInfo, sizeof(FILEINFO));
fileInfo.uStructSize = sizeof(FILEINFO);
L_INT nSuccess = LeadFile.GetInfo(&fileInfo, sizeof(FILEINFO), FILEINFO_TOTALPAGES);
</code>

nSuccess has value -9.

Similarly:
<code>
LBitmap lb;
nSuccess = lb.Load(filename, 0, ORDER_BGRORGRAY, nPage);
</code>

If I try this I get a slightly different error code -2002 (invalid parameters):
<code>
LFile rawfile;
rawfile.SetFileName(filename);
nSuccess = rawfile.LoadFile(0, ORDER_RGB, LOADFILE_ALLOCATE | LOADFILE_STORE);
</code>

So what have I forgotten to do????
   Report 
  06-16-2008, 11:33
Adnan Ismail is not online. Last active: 8/14/2008 1:40:07 PM Adnan Ismail



Top 10 Posts
Joined on 07-31-2006
Posts 1,124
Re: Loading txt files - invalid file format
Reply Quote
Please make sure that the Lftxt15u.dll DLL exist in the same folder where you deploy the Ltfil15u.dll.
Adnan Ismail
LEADTOOLS Technical Support

   Report 
  06-17-2008, 4:39
jjwalters is not online. Last active: 7/17/2008 10:20:22 AM jjwalters

Top 500 Posts
Joined on 06-11-2008
Posts 11
Re: Loading txt files - invalid file format
Reply Quote
Hi
I have installed the SDK on my PC as I'm still in the development phase. Both dlls are in the same directory D:\Program Files\LEAD Technologies\LEADTOOLS Class Library EVAL 15\Bin\API\Win32\
So it must be something else. None of the LeadTools examples seem to load txt files either.
There must be something else I've missed.
Thanks
Jordan
   Report 
  06-17-2008, 9:29
Adnan Ismail is not online. Last active: 8/14/2008 1:40:07 PM Adnan Ismail



Top 10 Posts
Joined on 07-31-2006
Posts 1,124
Re: Loading txt files - invalid file format
Reply Quote
Jordan,
Before loading the TXT files, you need to use the LFileSettings::SetTXTOptions and set the options for loading your file. This is shown in our Main C++ Class library demo:
LEADTOOLS 15\EXAMPLES\CLASSLIBRARY\MSVC\MainDemo

You can find it in "Demo.cpp" file inside the 'void CDemo::OnPreferencesLoadtextfiles()' function.

Adnan Ismail
LEADTOOLS Technical Support

   Report 
  06-17-2008, 11:51
jjwalters is not online. Last active: 7/17/2008 10:20:22 AM jjwalters

Top 500 Posts
Joined on 06-11-2008
Posts 11
Re: Loading txt files - invalid file format
Reply Quote
Hello Adnan
Yep, that did the trick.
One comment though. The Main Demo does this

L_INT nRet;
FILETXTOPTIONS TxtOptions;

nRet = LFileSettings::GetTXTOptions( &TxtOptions, sizeof( TxtOptions ) );
if( SUCCESS == nRet )
{
TxtOptions.bEnabled = !(TxtOptions.bEnabled);
LFileSettings::SetTXTOptions( &TxtOptions );
}

and doesn't see to need to set teh size of TxtOptions.uStructSize

However if I do this nRet = 0. So I end up having to do this:
FILETXTOPTIONS TxtOptions;
ZeroMemory(&TxtOptions, sizeof(TxtOptions));
TxtOptions.uStructSize = sizeof(TxtOptions);

L_INT nRet = LFileSettings::GetTXTOptions(&TxtOptions, sizeof(TxtOptions));
if(SUCCESS == nRet)
{
TxtOptions.bEnabled = L_TRUE;
LFileSettings::SetTXTOptions(&TxtOptions);
}

   Report 
Post
LEAD Support Fo... » Developer » File Formats » Loading txt files - invalid file format

Powered by Community Server, by Telligent Systems