Question: 

Wouldn't it be really nice if Atalasoft had a TWAIN device certification program?

Answer:

Sure would.

checkmark

Yep.  That's right.  Pretty soon we'll have a certification program in place for manufacturers of scanners, and other capture devices to certify their hardware  as "Plays Nice with Atalasoft Products"; although, the actual marketing message probably will be a bit more elegant than that. 

So, what is it that we're currently thinking that should be part of the certification?  This is what we've got so far all of which comes right out of the Atalasoft.DotTwain assembly,

Methods:  Acquire, BackgroundDetection, CanOpen, Close, Disable, Dispose, Enable, Finalize, GetConditionCode, GetSupportedBarCode, GetSupportedBitDepths, GetSupportedBrightnessValues, GetSupportedCapabilities, GetSupportedCompressionModules, GetSupportedContrastValues, GetSupportedImageFormats, GetSupportedJpegPixelTypes, GetSupportedJpegPixelQualityTypes, GetSupportedNativeResolutions, GetSupportedOverscanModes, GetSupportedPixelTypes, GetSupportedResolution, GetSupportedTransferMethods, GetSupportedUnitTypes, Open, LoadParameters, LoadXmlParameters, SaveParameters, SaveXmlParameters, ShowUserInterface

 Properties:  Alarms,  AutoBrightness, AutoDiscardBlankPages, AutomaticBorderDetection, AutomaticDeskew, AutomaticRotate, BarCode, Bitdepth, BitDepthReduction, Brightness, Compression, Contrast, Controller, CustomDataSupported, DeviceEvents, DisplayProgressIndicator, DocumentFeeder, Duplex, DuplexEnabled, EnableInterfaceOnly, FileFormat, FileSystem, Frame, FrameSize, InterfaceControllable, JpegPixelType, JpegQuality, LampState, Lastreturncode, MinimumHeight, MinimumWidth, NativeResolution, ModalAquire, Online, Overscan, PaperDetectable, PhysicalHeight, PhysicalWidth, PixelFlavor, PixelType, Resolution, State, ThreadingEnabled, Threshold, TransferCount, TransferMethod, Units, ReacquireAllowed

That's quite a bit, even with out getting into each of the details of each one of those methods or propeties, but before you can start, you need to find out what the attached device reports it can do.  I'm going to do this with DotTwain as it is very straightforward in a WinForm application.  

The first thing you need to do is find the attached device list for your system:

 

private void LoadDeviceNames()

{

     // Never assume that a system has any acquisition devices.

     if (!this.acquisition1.SystemHasTwain || this.acquisition1.Devices.Count == 0)          

           return;

     string defaultDevice = this.acquisition1.Devices.Default.Identity.ProductName;

     // Add a menu item for each device.

     foreach (Device dev in this.acquisition1.Devices)

     {

          if (dev.Identity.ProductName == defaultDevice)

          {

               this.device = dev;

         }

        this.comboBox1.Items.Add(dev.Identity.ProductName);

     }

     try

     {

     this.device.Open();

     TwainResolution res = this.device.Resolution;

     }

     catch (Exception ex)

     {

     MessageBox.Show("There was an exception trying to open the system      default device.\r\n" + ex.Message, "Default Device Failed");

     CertFailed();

     }

     finally

     {

     this.device.Close();

     }

}

 

In the WinForm app, I have a combobox (combobox1) that gets populated with the names of the attached TWAIN devices. When I select one of them, it fires the following bit of code:

 

 

private void button1_Click(object sender, EventArgs e)

{

     //Get the selected device's capabilities.

     string deviceName = this.comboBox1.SelectedItem.ToString();

     try

     {

          device = acquisition1.Devices.GetDevice(deviceName);

          device.Open();

          capabilities = device.GetSupportedCapabilities();

          CertPassed();

      }

 

     catch (Exception openingException)

     {

          string error = openingException.ToString();

          MessageBox.Show(error);

          CertFailed();

     }

     finally

     {

          device.Close();

     }

}

 

..Which doesn't do much yet, but is a start in comparing the list of supported capabilites reported by the device to the list of things that I think it should do; which is exactly what I'll write about next time.