The following steps show how to loop through all pages of a multipage 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.
Declare the following variables:
LBitmapBase BitmapBase; // LEAD bitmap
LFile LeadFile; // File operations
FILEINFO FileInfo = {0}; // File info
L_INT PageNumber, TotalPages; // Page numbers
L_TCHAR szOutFileName[MAX_PATH]; // Output file name
Determine the number of pages in the file:
BitmapBase.SetFileName (TEXT("MultiPage.tif"));
LeadFile.GetInfo (&FileInfo, sizeof(FILEINFO));
TotalPages = FileInfo.TotalPages;
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 loop
BitmapBase.Load (TEXT("MultiPage.tif"), 0, ORDER_BGRORGRAY, PageNumber);
// Check that it is properly loaded and allocated
if(BitmapBase.IsAllocated ())
{
// Perform specific processing on the page, such as flipping it
BitmapBase.Flip ();
// Save the page to a separate file
wsprintf(szOutFileName, TEXT("PageNumber%4.4d.bmp"), PageNumber);
BitmapBase.Save (szOutFileName, FILE_BMP, BitmapBase.GetBitsPerPixel (), 0, 0);
} //if Allocated
} //for loop
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document