I read – and have read in the past – a new request for handling multiple page tiff files. I looked at available libraries out there and found out, that “Freeimage” might help here. “FreeImage” is a good candidate, because it offers “standard calling” conventions, supported by VASmalltalk.
Here is a very early and simple wrapper for some API calls offered by this library. Only small tests have been done, but it can be used as a start:
This is a code example for opening a TIFF file and write out each page into a different file:
loadSingleTiffFileAndExportPages "MSKFreeImageWrapper loadSingleTiffFileAndExportPages" | aWrapper freeImageFormatConstant ptrToFIMULTIBITMAP | aWrapper := MSKFreeImageLibraryWrapper new. (ptrToFIMULTIBITMAP := aWrapper openMultiBitmap: FIF_TIFF filename: 'fax2d.tif' createNew: false readOnly: true inMemory: true flags: 0) isAbtError ifFalse:[ | nrOfPages | nrOfPages := aWrapper getPageCount: ptrToFIMULTIBITMAP . Transcript cr ; show: 'You find ',nrOfPages printString,' pages in this TIFF file'. 0 to: nrOfPages - 1 do: [ :eachPageNumber | | ptrToFIBITMAP | (ptrToFIBITMAP := aWrapper lockPageNumbered: eachPageNumber inMultiBitmap: ptrToFIMULTIBITMAP) isAbtError ifFalse:[ | sizeOfPicture memoryStream | (aWrapper save: FIF_TIFF bitmap: ptrToFIBITMAP filename: (eachPageNumber asString,'.tiff') flags: 0) ifTrue:[ Transcript show: 'Exported page Nr. ',eachPageNumber printString. ]. aWrapper unlockPageBitmap: ptrToFIBITMAP inMultiBitmap: ptrToFIMULTIBITMAP changed: false . ]. ]. aWrapper closeMultiBitmap: ptrToFIMULTIBITMAP flags: 0 ].