Quantcast
Channel: Saraff.Twain.NET
Viewing all articles
Browse latest Browse all 419

Updated Wiki: Native Mode Transfer

$
0
0

Native Mode Transfer

Native mode is the default mode. There is one potential limitation that can occur in a Native mode
transfer. That is, there may not be an adequately large block of RAM available to hold the image.
Enable native mode transfer as follows:

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

Image transmission is implemented as follows: for each of the received image is raised EndXfer event, and after completion of scanning is raised AcquireCompleted event. In the AcquireCompleted event handler can be used the GetImage method and the ImageCount property for retrieving all scanned images.

privatevoid _twain32_EndXfer(object sender,Twain32.EndXferEventArgs e) {
    try {
        using(var _image = e.Image) {
            _image.Save("filename.tif",ImageFormat.Tiff);
        }
   } catch(Exception ex) {
        MessageBox.Show(ex.Message,ex.GetType().Name,MessageBoxButtons.OK,MessageBoxIcon.Error);
    }
}

privatevoid _twain32_AcquireCompleted(object sender,EventArgs e) {
    try {
        for(int i=0; i<this._twain32.ImageCount; i++) {
            using(var _image=this._twain32.GetImage(i)){
                _image.Save(Path.GetTempFileName());
            }
        }
    } catch(Exception ex) {
        MessageBox.Show(ex.Message,ex.GetType().Name,MessageBoxButtons.OK,MessageBoxIcon.Error);
    }
}


Viewing all articles
Browse latest Browse all 419

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>