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 : Friday, September 14, 2007 8:18:36 AM(UTC)
ptrzeciak

Groups: Registered
Posts: 13


First some background: I process files coming from the ImagePlus system. Some of them are MO:DCA, some are TIFFs. In one case I get a single file from the ImagePlus (multipage TIFF). The system processes all files in the same way, so a mulitpage TIFF is opened, image by image, and saved into another copy as a multipage TIFF.
The problem: when the first image is small (that comes from a scanner), it seems that all images in the file end up cut off. Is this a limitation of the TIFF (multipage) format, or there is an option I need to set to save each image into the multipage file correctly. The version we are using is V13.
Thanks for any help!!!
 

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 : Friday, September 14, 2007 9:57:24 AM(UTC)

BoydP  
Guest

Groups: Guests
Posts: 3,022

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

What interface are you using?  Could you please post your code which reads and saves the files as well as images which display the problem?  If you are going to upload images to the forum make sure you put them in a zip file first.
 
#3 Posted : Friday, September 14, 2007 10:24:37 AM(UTC)
ptrzeciak

Groups: Registered
Posts: 13


Here is the code:

imageData->ImageOptions.PageNumber = 1;
uFlags = FILEINFO_TOTALPAGES;

nRet = L_FileInfo( imageData->Source.szFilename, &(imageData->Source.FileInfo), uFlags, &imageData->ImageOptions);
if (nRet!=SUCCESS) {
    return(-1);
}
else {
       imageData->iRealPages = imageData->Source.FileInfo.TotalPages;
}
for (imageData->iCurrentConvImage = 1; imageData->iCurrentConvImage <= imageData->iRealPages; imageData->iCurrentConvImage++) {
    L_GetDefaultLoadFileOption( &(imageData->ImageOptions), sizeof(imageData->ImageOptions) );
    L_GetDefaultSaveFileOption( &(imageData->ImageOptionsSave), sizeof(imageData->ImageOptionsSave) );
    imageData->ImageOptions.PageNumber = imageData->iCurrentConvImage;
    imageData->Source.FileInfo.PageNumber = imageData->iCurrentConvImage;
       nRet = L_LoadBitmap( imageData->Source.szFilename, &(imageData->Source.hBitmap), 1, ORDER_BGR, &imageData->ImageOptions, &imageData->Source.FileInfo);
       if (nRet!=SUCCESS) {
           return(-1);
       }
    imageData->ImageOptionsSave.Passes = imageData->ImageOptions.Passes;
    imageData->ImageOptionsSave.GlobalLoop = imageData->ImageOptions.GlobalLoop;
    imageData->ImageOptionsSave.PageNumber = imageData->iCurrentConvImage;
    imageData->ImageOptionsSave.Flags = ESO_NOSUBFILETYPE|ESO_REPLACEPAGE;

       nRet = L_SaveBitmap( imageData->Target.szFilename, &(imageData->Source.hBitmap), imageData->iImageType, imageData->iBitsPP, imageData->iQFactor, &imageData->ImageOptionsSave );
       if (nRet != SUCCESS) {
           return(-1);
       }
       L_FreeBitmap( &(imageData->Source.hBitmap) );
}



Images attached... as you notice, the first image is only half-page tall, and so is the rest.

Thanks!!!
File Attachment(s):
2007-09-14-15-39-35-138764_001.zip (281kb) downloaded 22 time(s).
 
#4 Posted : Friday, September 14, 2007 12:05:34 PM(UTC)

BoydP  
Guest

Groups: Guests
Posts: 3,022

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

Could you please post the original images?  That way I can mess around with your code over here to see if I can produce the same results or solve the problem.
 
#5 Posted : Monday, September 17, 2007 4:21:44 AM(UTC)
ptrzeciak

Groups: Registered
Posts: 13


Included are two files in a zip:

1. 2007-09-17-09-04-35-463733_001.MCA is an image (could be a TIFF or a MO:DCA file) that comes from the mainframe ImagePlus system, and is saved as a binary stream from a low-level socket interface.
2. 2007-09-17-09-04-35-463733_001.tif is a converted file

Please, let me know if it helps with your debugging.
Thanks!!!
File Attachment(s):
2007-09-17-09-04-35-463733.zip (722kb) downloaded 30 time(s).
 
#6 Posted : Monday, September 17, 2007 7:11:56 AM(UTC)

BoydP  
Guest

Groups: Guests
Posts: 3,022

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

Add the following code, this should fix your issue.  Insert it directly before L_LoadBitmap(...):

nRet
= L_FileInfo( imageData->Source.szFilename,
&(imageData->Source.FileInfo), uFlags, &imageData->ImageOptions);
if (nRet!=SUCCESS) {
    return(-1);
}

The only time you populate FileInfo, which controls the size of the bitmap to load, was against the first page of the image.  Each time after that FileInfo held the information for the first page of the image, you never updated it for subsequent pages which is why the images were all the same size.  Inserting the above code should resolve your issue.

I hope this has helped and if you have anymore issues please feel free to ask.
 
#7 Posted : Monday, September 17, 2007 7:45:58 AM(UTC)
ptrzeciak

Groups: Registered
Posts: 13


Ahh... I did not realize that I need L_FileInfo() for anything else than getting the total number of pages. Thanks for your help!!! Greatly appreciated!!!
 
#8 Posted : Monday, September 17, 2007 8:12:43 AM(UTC)

BoydP  
Guest

Groups: Guests
Posts: 3,022

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

I forget to mention the second way to accomplish this task.  The following line of code inside the for loop can be removed:

imageData->Source.FileInfo.PageNumber = imageData->iCurrentConvImage;

Instead of passing "
imageData->Source.FileInfo" to L_LoadBitmap(...) you can pass in NULL and the image produced will be what you are looking for.  This approach eliminates the unneccessary overhead of querying the file each time for its dimensions.  With this approach you do not need to make the changes I recommended in the above post, these are two separate ways of accomplishing this task.
 
#9 Posted : Monday, September 24, 2007 5:02:47 AM(UTC)
ptrzeciak

Groups: Registered
Posts: 13


Thank you. The first suggestion one worked, and I'll try the second one next.
 
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.235 seconds.