Dynamic Web TWAIN: How to automatically deskew an image?

Generally, there are two ways to automatically deskew an image. Method No.1 - Use Dynamic Web TWAIN's built-in methods. Below are the basic steps:

  1. Calculate the skew angle by using GetSkewAngle Method.
    Angle = DWObject.GetSkewAngle(DWObject.CurrentImageIndexInBuffer);
  2. Use Rotate method to de-skew the image.
    DWObject.Rotate(DWObject.CurrentImageIndexInBuffer,-Angle, 0);

If you want to do de-skew to each scanned image, you can call the above code in OnPostTransfer event.

Method No.2 - Use custom capability of the scanner, which requires the support of the scanner itself.

   DWObject.Capability = 4433;  //AutoDeskew
    DWObject.CapType = 5;      //TWON_ONEVALUE
    DWObject.CapValue = 0;
    bRet = DWObject.CapSet();