The following steps show how to loop through all pages of a multi-page TIFF file and extract each page, process it individually, and save it into a separate file.
NOTE: To save a region inside a TIFF file, you must have an unlocked Document, Vector, or Medical Imaging license.
1. |
Declare the following variables: |
LBitmapBase BitmapBase; // LEAD bitmapLFile LeadFile; // File operationsFILEINFO FileInfo = {0}; // File infoL_INT PageNumber, TotalPages; // Page numbersL_TCHAR szOutFileName[MAX_PATH]; // Output file name
2. |
Determine the number of pages in the file: |
BitmapBase.SetFileName (TEXT("MultiPage.tif"));LeadFile.GetInfo (&FileInfo, sizeof(FILEINFO));TotalPages = FileInfo.TotalPages;
3. |
Loop through the pages of the file; performing specific processing on each page, then save each page into a separate file: |
for (PageNumber=1; PageNumber<=TotalPages; ++PageNumber){// Load the next image in the loopBitmapBase.Load (TEXT("MultiPage.tif"), 0, ORDER_BGRORGRAY, PageNumber);// Check that it is properly loaded and allocatedif(BitmapBase.IsAllocated ()){// Perform specific processing on the page, such as flipping itBitmapBase.Flip ();// Save the page to a separate filewsprintf(szOutFileName, TEXT("PageNumber%4.4d.bmp"), PageNumber);BitmapBase.Save (szOutFileName, FILE_BMP, BitmapBase.GetBitsPerPixel (), 0, 0);} //if Allocated} //for loop
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
