In native mode transfer, the TWAIN source places the image in a Windows shared memory area called the Global Heap. The TWAIN source sends the handle to that memory area to our application. Our application can connect to the memory area using the handle.
The Native Image buffer is always in 'DIB' (device independent bitmap) format on Windows. DIB files cannot be displayed directly in Python. The twain module provides a function (DIBtoBMFile()) to convert the file to a Windows Bitmap File, which can be loaded into an Image. The twain module also provides a function (DIBtoXBMFile()), which converts the file to an XBM (X-windows bitmap) format, which can be displayed in a Tk label.
Once the image has been processed, the application must 'free' the handle, using the GlobalHandleFree() function. Otherwise the memory will not be available to any Windows Applications.
In File based transfer, the TWAIN source places the image into a windows disk file. Once the transfer has been completed the file exists. The application is responsible for the file and should provide house-keeping functions for the files.
The application can specify both the filename and the file format prior to commencing the transfer. The available file formats for your TWAIN source can be retrieved using the ICAP_IMAGEFILEFORMAT capability. The file format and name can both be specified using the SetXferFileName method.