twain / twain-cs

A C# interface for TWAIN
167 stars 66 forks source link

Some requests for ShowImage 1) STS param, 2) Image Type param, 3) Metadata param (or combine 2 into 3) #4

Closed kolomiets closed 7 years ago

kolomiets commented 7 years ago

Reported by vin-finn on 2014-02-20 21:47 UTC Love this module. I'm using it in a Web based scanner service. I needed to modify ShowImage to send the STS param so that I would know the reason for the call into ShowImage when the bitmap is null. In my showimage callback I keep track of numpages scanned and if the a_bitmap is null, numpages is 0, sts != TWAINCSToolkit.STS.SUCCESS I generate an error message based on: if (sts == TWAINCSToolkit.STS.CANCEL)
{ TS_ProgressMsg = "Paper not loaded, job cancelled, please load paper"; } else { TS_ProgressMsg = "Job terminated with error: "+sts.ToString(); }

If numpages is >0 then I show a cancel message and I post the sts.ToString().

In addition to STS it would be very useful to know the image type that has been stored. I know where the images are stored since I set that location but the scanned image can be TIF, JPG or BMP, and I have to look in the folder to figure that out. It would be useful to be told the image type via a System.Drawing.Imaging.ImageFormat type of parameter.

I know I can take the bitmap, but I don't use that bitmap since I can't display the image at the time of the callback. The GUI has to query for status and upon discovery of a new image call for the image. So the ShowImage callback triggers the event, and later I access the image via the stored image. If it is appropriate to have two showimage types, one as an event without the image as a parameter and more notification information on just what was stored, that would be preferable. I extract metadata from the images and it would be very nice to be provided that metadata at callback time, rather than the image itself.

Thank you for such a great library. Vinnie