TWAIN

ss.SetCapability(twain.ICAP_IMAGEFILEFORMAT, twain.TWTY_UINT16,
twain.TWFF_JFIF)
扫描A3
ss.GetSourceName()得到源名称
将名称写入括号,则自动选择
>>> ss.HideUI() 隐藏界面
>>> ss.destroy() 断开连接
ss.GetIdentity()
{'Info': '1.123', 'SupportedGroups': 1073741827, 'Language': 13,
'MajorNum': 1, 'ProtocolMinor': 0, 'ProductName': 'Canon DR-6030C
TWAIN', 'ProductFamily': 'Canon DR-6030C Driver', 'ProtocolMajor': 2,
'Country': 1, 'MinorNum': 123, 'Manufacturer': 'Copyright CANON
ELECTRONICS INC. '}
ss.GetImageInfo()
{'YResolution': 300, 'BitsPerSample': [8, 0, 0, 0, 0, 0, 0, 0],
'ImageLength': 3507, 'Compression': 0, 'PixelType': 1, 'BitsPerPixel':
8, 'Planar': 0, 'XResolution': 300, 'ImageWidth': 2480,
'SamplesPerPixel': 1}
水平解析度 (xResolution)
aa=ss.RequestAcquire(1,1)显示扫描仪设置界面
aa=ss.RequestAcquire(0,0)不显示扫描仪设置界面
ss.GetImageLayout()
((0.0, 0.0, 8.17476, 11.4522), 1, 1, 1)

# -*- coding: cp936 -*-
import twain,sys,time
from multiprocessing import Process
def aab():
   rv = ss.XferImageNatively()
   print(rv)
   
sm = twain.SourceManager(0)

ss = sm.OpenSource('Canon DR-6030C TWAIN')



print(ss)
#sys.exit()

aa=ss.RequestAcquire(0,0)#1,1显示扫描仪用户界面

#ss.LogMessage(self.ProductName +':'+'等待扫描仪')
rv = ss.XferImageNatively()
#rva=ss.XferNatively
print(rva)
#sys.exit()
print(aa)
print(ss.GetImageInfo())
while True:
       rv = ss.XferImageNatively()
       #print(ss.Heap)
       print(rv)
       if rv is None:
           break
       else:
           (handle, count) = rv
           print(rv)
           aj=twain.GlobalHandleAllocate(handle)
           twain.GlobalHandleFree(aj)
                 
           break
sys.exit()
a=1
while a<=10:
   aab()
   a=a+1
time.sleep(1)
ss.CancelAllPendingXfers()#取消扫描

sys.exit()
if rv:
   (handle, count) = rv
   pass
twain.DIBToBMFile(handle, 'image.bmp')

 

上一篇:FFT 学习笔记


下一篇:python twain 扫描