denisenkom / pytwain

TWAIN library using ctypes bindings
Other
45 stars 23 forks source link

BUG - python cant set duplex, but with VueScan and other applications duplex works #9

Closed hubplace closed 8 years ago

hubplace commented 8 years ago

Duplex scan is not working and also always getting 1 BMP files. Is this a BUG? how can i make sure the duplex works. I am using Windows 8.1 64-bit Python27.

import twain
from time import *
index = 0;

def next(ss):
  try:
    print ss.GetImageInfo()
    return True
  except:
    return False

def capture(ss):
  global index
  try:
    rv = ss.XferImageNatively() 
    fileName = str(index) + '_image.bmp';
    index = index + 1;
    print rv;
    if rv:
      (handle, count) = rv
      twain.DIBToBMFile(handle, fileName) 
  except:
    print "XferImageNatively"

sm = twain.SourceManager(0)
#ss = sm.OpenSource('WIA-EPSON DS-510 #2')
ss = sm.OpenSource()

try:    
  #ss.SetCapability(twain.CAP_DUPLEXENABLED, twain.TWTY_BOOL, True)
  ss.set_capability(twain.CAP_DUPLEX, twain.TWTY_BOOL, False)
except:
  print "Could not set duplex"

#print "acquire image"
ss.RequestAcquire(0,0)

while next(ss):
  capture(ss)