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 : Wednesday, June 20, 2007 5:23:54 AM(UTC)
bcjenkins

Groups: Registered
Posts: 9


Hello, first time poster, and I am sure this is a stupid question however - I am trying to combine two single tiff's into a multi-page tiff:  (C++ 6.0)

 

CString csFront;  // holds fully quaified path to front image

CString csBack;  //holds fully qualified path to back image.

CString csMulti  // holds fully qualified path to multi page file,   DOES NOT EXIST YET


  LFile leadFront;
  LFile leadBack;

  leadFront.SetFileName( (LPTSTR)(LPCSTR)csFront );   //this requires a char *,   we only have cstrings...
  leadBack.SetFileName( (LPTSTR)(LPCSTR)csBack );
    
  //have to load the file into object.
  leadFront.LoadFile(FILE_TIF);
  leadBack.LoadFile(FILE_TIF);

  //change the file name in the object...
  leadFront.SetFileName( (LPTSTR)(LPCSTR)csMulti );
  leadBack.SetFileName( (LPTSTR)(LPCSTR)csMulti );
    
  //saving to multi-page tiff... 
  leadFront.SaveFile(FILE_TIF, 0 , SAVEFILE_MULTIPAGE );   

  leadBack.SaveFile(FILE_TIF, 0 , SAVEFILE_MULTIPAGE );

 

 

Am I trying to do this the hard way?  This isnt working....  As far as I can tell the save files arent doing anything.
  

 

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 : Wednesday, June 20, 2007 7:29:01 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


Your logic is correct, but I think that your call to SaveFile is not what you are expecting.  The SaveFile function has 5 parameters, but you only specific three.  Most likely, it is interpreting your SAVEFILE_MULTIPAGE as the QFactor parameter rather than the uFlags parameter.  Try saving with all 5 parameters:

  leadFront.SaveFile(FILE_TIF, 0 , 0, SAVEFILE_MULTIPAGE, NULL );   

  leadBack.SaveFile(FILE_TIF, 0 , 0,  SAVEFILE_MULTIPAGE, NULL );

If that does not work, then please post a small sample project (NOT your entire application) that isolates your problem so I can try to reproduce it here. 

NOTE: If you are attaching a project or file to the forums...
1.) Zip the file(s) up.
2.) Make sure it is less than 10 MB.  If it is larger, please send an email to support@leadtools.com or  give us your email address and we'll send you FTP instructions.
3.) Remove ANY AND ALL unlock codes and LEADTOOLS DLLs.
4.) Do not click the preview button, the attachment will not show up when you post it.
 
If you do not wish to post your file(s) on the forum since they are publically viewable, please send an email to support@leadtools.com and make sure that you include a link to this forum post.

 
#3 Posted : Wednesday, June 20, 2007 9:00:44 AM(UTC)
bcjenkins

Groups: Registered
Posts: 9


Thank you for the save advice, however I am still getting the same issues.  the adjusted test code looks like:

 

  LFile leadFront;
  LFile leadBack;

  csFront = "C:\\test\\1.tif";
  csBack  = "C:\\test\\2.tif";
  csMulti = "C:\\test\\multi.tif";

  leadFront.SetFileName( (LPTSTR)(LPCSTR)csFront );   //this requires a char *,   we only have cstrings...
  leadBack.SetFileName( (LPTSTR)(LPCSTR)csBack );
    
  //have to load the file into object.
  int i = leadFront.LoadFile(FILE_TIF);
  int j = leadBack.LoadFile(FILE_TIF);

  //change the file name in the object...
  leadFront.SetFileName( (LPTSTR)(LPCSTR)csMulti );
  leadBack.SetFileName( (LPTSTR)(LPCSTR)csMulti );
    
  //saving to multi-page tiff... 
  leadFront.SaveFile(FILE_TIF, 0 , 0, SAVEFILE_MULTIPAGE, NULL );  
  leadBack.SaveFile(FILE_TIF, 0 , 0,  SAVEFILE_MULTIPAGE, NULL );

 

 

 

However i and j are giving a return code of -1002 which is a pramater error. so I rewrote the load to the following:

 

  //have to load the file into object.
  int i = leadFront.LoadFile(0, LOADFILE_ALLOCATE|LOADFILE_STORE, 0, 0, NULL);
  int j = leadBack.LoadFile(0, ORDER_GRAY, LOADFILE_ALLOCATE|LOADFILE_STORE, NULL, NULL);

 

both calls to load produce the same error, t-1002.   the files exist in c:\test\ ... ideas?

 

 

 
#4 Posted : Wednesday, June 20, 2007 11:07:19 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


Did you create a BitmapBase object for the file to be loaded into?  for example:

LBitmapBase LeadBitmap ;
LUserFile        UserLeadFile ;

UserLeadFile.SetBitmap(&LeadBitmap);
 
#5 Posted : Wednesday, June 20, 2007 12:10:10 PM(UTC)
bcjenkins

Groups: Registered
Posts: 9


Thank you for your efforts, I believe I am almost there.

After creating a bitmap base, I got some different error codes regarding dlls not being loaded, I researched your forums regarding that error message and I have the LoadFile calls returning  '1'  ( i & j )

However, the SaveFile calls ( in red below) are returning -1002  ( k & l )  parameter error again.  The filename c:\test\multi.tif does not exist, could that be causing the save to fail????

 

 

  //bcj load all of the dll's...
  if ( ( LBase::LoadLibraries( LT_ALL_LEADLIB ) & LT_ALL_LEADLIB ) == 0L )
  {
   AfxMessageBox( _T( "Unable to load the Lead Tools Screen Library." ) );
   return ESTUB_EMPTY_STRING;
  }


  LFile leadFront;
  LFile leadBack;

  LBitmapBase LeadBitmapFront;
  LBitmapBase LeadBitmapBack;

  leadFront.SetBitmap(&LeadBitmapFront);
  leadBack.SetBitmap(&LeadBitmapBack);

  csFront = "C:\\test\\1.tif";
  csBack  = "C:\\test\\2.tif";
  csMulti = "C:\\test\\multi.tif";

  leadFront.SetFileName( (LPTSTR)(LPCSTR)csFront );   //this requires a char *,   we only have cstrings...
  leadBack.SetFileName( (LPTSTR)(LPCSTR)csBack );
    
  //have to load the file into object.
  int i = leadFront.LoadFile(0, LOADFILE_ALLOCATE|LOADFILE_STORE, 0, 0, NULL);
  int j = leadBack.LoadFile( 0, LOADFILE_ALLOCATE|LOADFILE_STORE, 0, 0, NULL);

  //change the file name in the object...
  leadFront.SetFileName( (LPTSTR)(LPCSTR)csMulti );
  leadBack.SetFileName( (LPTSTR)(LPCSTR)csMulti );
    

  //saving to multi-page tiff... 
  int k = leadFront.SaveFile(FILE_TIF, 0 , 0, SAVEFILE_MULTIPAGE, NULL );  
  int l = leadBack.SaveFile(FILE_TIF, 0 , 0,  SAVEFILE_MULTIPAGE, NULL );

 

 

 
#6 Posted : Wednesday, June 20, 2007 12:25:48 PM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


No, you should be able to create files that don't currently exist on the file system.  Also, the error number you are getting means Invalid Parameter(s) passed.  If that were the problem, I'd think it would return something like file not found or error writing file.

Do you get the same error if you try to save the files to a file that does already exist?  If so, then the non-existing file might have some merit.  In that case try leaving out the SAVEFILE_MULTIPAGE flag on your first call and then use the flag when you save the second image.  Perhaps since it is appending to a file that it expects it to already be there.

You  might also want to try changing your QFactor parameter.  Try passing 2 rather than 0.

Also, I would check the LFile::IsValid function. 

You should also be able to accomplish the same task using the LBitmapBase object because it also has a load and save function that should allow you to combine images into one multipage image.
 
#7 Posted : Thursday, June 21, 2007 4:54:46 AM(UTC)
bcjenkins

Groups: Registered
Posts: 9


OK - I still couldnt get the SaveFile to work, no matter what I tried, I always got that -1002 error.

 

However - I took your BitmapBase advice, and wrote this:

 

  LBitmapBase BitmapBase;
  int m = BitmapBase.Load ("C:\\test\\1.tif", 0,ORDER_BGR, NULL);
  int n = BitmapBase.Save("C:\\test\\multi.tif", FILE_TIF,   0,            1,    1 ,   SAVE_APPEND);
  
  m = BitmapBase.Load ("C:\\test\\2.tif", 0,ORDER_BGR, NULL);
  n = BitmapBase.Save("C:\\test\\multi.tif", FILE_TIF,   0,            0,    2 ,   SAVE_APPEND);
  //                            file         format,    bitspixel   Qfac,   page# , flags 

and it works great!!!    Thank you for all of your help!!!  

 

hopefully this will help out the next programmer.....

 

 
#8 Posted : Thursday, June 21, 2007 10:50:11 AM(UTC)

GregR  
GregR

Groups: Registered, Tech Support, Administrators
Posts: 764


Glad it's working for you.
 
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.096 seconds.