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.
Declare the following variables:
BITMAPHANDLE LeadBitmap = {0}; // LEAD bitmapFILEINFO FileInfo = {0}; // File infoL_INT PageNumber, TotalPages; // Page numbersLOADFILEOPTION LoadFileOption = {0}; // Loading optionschar szOutFileName[MAX_PATH]; // Output file name
Determine the number of pages in the file:
L_FileInfo("MultiPage.tif", &FileInfo, sizeof(FILEINFO), FILEINFO_TOTALPAGES, NULL);TotalPages = FileInfo.TotalPages;
Loop through the pages of the file; performing specific processing on each page, then save each page to a separate file:
L_GetDefaultLoadFileOption(&LoadFileOption, sizeof(LOADFILEOPTION));for (PageNumber=1; PageNumber<=TotalPages; ++PageNumber){// Load the next image in the loopLoadFileOption.PageNumber = PageNumber;L_LoadBitmap("MultiPage.tif", &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, &LoadFileOption, NULL);// Check that it is properly loaded and allocatedif(LeadBitmap.Flags.Allocated){// Perform specific processing on the page, such as flipping itL_FlipBitmap(&LeadBitmap);// Save the page to a separate filewsprintf(szOutFileName, "PageNumber%4.4d.tif", PageNumber);L_SaveBitmap(szOutFileName, &LeadBitmap, FILE_TIFLZW, LeadBitmap.BitsPerPixel, 0, NULL);// Free the image from memoryL_FreeBitmap(&LeadBitmap);} //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
