Accusoft.TwainPro9.Net
Fast Saving Multi-page TIFF Files
This topic discusses the fast saving of multi-page TIFF files generally over 1000 pages.

When the UseIFDOffset property is false (default), the image is appended to the end of the multi-page TIFF. Due to the linked format of TIFF, the software must traverse all the link pointers to identify the location to which the new page will be appended. The greater the number of pages in the target TIFF file, the longer the write process takes. (Typically, if the target file has more than 1000 pages, the write speed will degrade substantially.)
 
Setting the UseIFDOffset property to true specifies that the control should write the image to the location stored in the IFDOffset property. This enables much faster writing of TIFF files with many pages because the software can seek to that location without traversing all previous pointer links. This process gives very predictable speeds in adding pages to a multi-page TIFF file.

If the file's IFDOffset ever became out of sync with the IFDOffset property value, file corruption could occur. To protect the application from inadvertently corrupting a saved mutli-page file, the Twain PRO 6 control takes the following measures:
  • If the application sets the UseIFDOffset property to true or false, the IFDOffset property is automatically set to zero. The application must then explicitly set the IFD Offset to be used.
  • Executing the SaveFile method will automatically set the UseIFDOffset property to false. The application must then explicitly set the value back to true as needed.
  • When the IFDOffset property is zero, a normal write (not fast TIFF write) will occur regardless of the UseIFDOffset value. The fast write will take place only when IFDOffset is set to non-zero and the UseIFDOffset is set to true.
C# Example
Copy Code
// This code demonstrates how to use the UseIFDOffset and IFDOffset properties to safely enable fast TIFF writing
 
        private Accusoft.TwainProSdk.TwainDevice twainDevice;
        Accusoft.TwainProSdk.SaveOptions mySaveOptions;
        int myIfdOffset = 0;
 
        public void SaveMultipageTifUsingIfd()
        {
            try
            {
                mySaveOptions.Tiff.MultiPage = true;
                outputFile = System.IO.Path.Combine(System.Environment.CurrentDirectory, "..\\..\\ifd.tif");
                twainDevice.StartSession();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
 
        public void twainDevice_Scanned(object sender, Accusoft.TwainProSdk.ScannedEventArgs e)
        {
            try
            {
                mySaveOptions.Tiff.UseIFDOffset = true;
                mySaveOptions.Tiff.IFDOffset = myIfdOffset;
                e.ScannedImage.SaveFile(outputFile, mySaveOptions);
                myIfdOffset = mySaveOptions.Tiff.IFDOffset;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

 

See Also

 

 


©2014. Accusoft Corporation. All Rights Reserved.

Send Feedback