Has anyone used the TWAIN module successfully on Windows?
Below is a code snippet for my attempt to capture a scanned image. Two issues:
1. The image is not displayed in the scrolled window.
2. A file on disk is created. But, when I try to view the created file using IrfanView, it displays an error message: "Decode error! Invalid or unsupported BMP file."
Any help would be greatly appreciated!
Thanks.
def ProcessXFer(self, event):
(handle, more_to_come) = self.SD.XferImageNatively()
tmpfilename = 'capture.bmp'
try:
twain.DIBToBMFile(handle, tmpfilename)
bmp = wx.Bitmap(tmpfilename, wx.BITMAP_TYPE_BMP)
except e:
errmsg = 'EXCEPTION %d: %s' % (e.args[0], e.args[1])
print errmsg
twain.GlobalHandleFree(handle)
# add image
staticbmp = wx.StaticBitmap(self.scrolledWindow1, wx.ID_STATIC, bmp)
···
--
------------------------------------------------------
Brian Wolf |
Activus Technologies Corporation |
brian@activustech.com | 410.367.2958 |
------------------------------------------------------
Helping organizations gain a competitive advantage |
through intelligent application of technology. |
------------------------------------------------------