View on GitHub

SARAFF SOFTWARE

All products / Saraff.Twain.NET / Contents

Disk File Mode Transfer

Enable disk file mode transfer as follows:

this._twain32.Capabilities.XferMech.Set(TwSX.File);

Image transmission is implemented as follows: for each image is raised SetupFileXferEvent event before obtaining, and is raised FileXferEvent event after receiving. After completion of scanning is raised AcquireCompleted event. But the ImageCount property value will be zero.

private void _twain32_SetupFileXferEvent(object sender,Twain32.SetupFileXferEventArgs e) {
    try {
        e.FileName=string.Format(@"FileXferTransfer_{0}.{1}",DateTime.Now.ToString("yyyyMMddHHmmss"),this._twain32.Capabilities.ImageFileFormat.GetCurrent().ToString().ToLower());
    } catch(Exception ex) {
        MessageBox.Show(ex.Message,ex.GetType().Name,MessageBoxButtons.OK,MessageBoxIcon.Error);
    }
}
private void _twain32_FileXferEvent(object sender,Twain32.FileXferEventArgs e) {
    try {
        this.CurrentBitmap=Image.FromFile(e.ImageFileXfer.FileName) as Bitmap;
    } catch(Exception ex) {
        MessageBox.Show(ex.Message,ex.GetType().Name,MessageBoxButtons.OK,MessageBoxIcon.Error);
    }
}

To select the required image file format used ImageFileFormat capability.

this._twain32.Capabilities.ImageFileFormat.Set(TwFF.Tiff);

Specified value should be supported by the DS.