This project has moved. For the latest updates, please go here.

SetCap TwCap.ICompression BadValue setting TwCompression.Lzw

Aug 12, 2016 at 9:13 PM
I am trying to set the capability for compression. I check to see if the capability is supported and set it with the following code:

if ((_twain.IsCapSupported(TwCap.ICompression) & TwQC.Set) != 0)
{
_twain.SetCap(TwCap.ICompression, TwCompression.Lzw);
}

I receive a TwainException ("Data parameter out of range."; ReturnCode = CheckStatus; ConditionCode = BadValue) with a StackTrace of at Saraff.Twain.Twain32._SetCapCore(TwCapability cap, TwMSG msg)
at Saraff.Twain.Twain32._SetCapCore(TwCap capability, TwMSG msg, Object value)
at Saraff.Twain.Twain32.SetCap(TwCap capability, Object value)
at WebCapture.Capture.TwainImageCapturer.init(String scannerId, String scannerName, Boolean showConfiguration) in C:\Repos\development\WebCapture\WebCapture.Capture\TwainImageCapturer.cs:line 55
at WebCapture.Capture.TwainImageCapturer.Begin(Action`1 onImageFileAvailables, Action onComplete, String scannerId, String scannerName, Boolean showConfiguration) in C:\Repos\development\WebCapture\WebCapture.Capture\TwainImageCapturer.cs:line 115

I have tried to set other compression values and get varying other issues / errors sometimes on the Acquire. I am using a Fujitsu fi-6140 with the device drivers from the Fujitsu website (http://www.fujitsu.com/global/support/products/computing/peripheral/scanners/fi/software/v9211600.html) Any help with this issue would be much appreciated.
Coordinator
Aug 13, 2016 at 6:03 AM
Hello, GuyTraveler.
Invoke the _twain.Capabilities.Compression.Get() method that get supported values.
Marked as answer by SARAFF on 8/27/2016 at 7:07 AM
Aug 15, 2016 at 2:34 PM
Thanks for the quick response. The values the get method returned were None, Group31D, Group31Deol, Group32D, Group4, Jpeg. I think the best solution for me going forward to guarantee compression will be to change my code to get the image as memory instead of file and apply compression to it then.
Coordinator
Aug 15, 2016 at 5:47 PM
Hello, GuyTraveler.
ICAP_COMPRESSION Allows the application and Source to identify which compression schemes they have in common for Buffered Memory and File transfers.
For File transfer since only certain file formats support compression, this capability must be negotiated after setting the desired file format with ICAP_IMAGEFILEFORMAT.
  • TWCP_NONE All Sources must support this.
  • TWCP_PACKBITS Can be used with TIFF or PICT
  • TWCP_GROUP31D,
  • TWCP_GROUP31DEOL,
  • TWCP_GROUP32D,
  • TWCP_GROUP4 Are all from the CCITT specification (now ITU), intended for document images (can be used with TIFF).
  • TWCP_JPEG Intended for the compression of color photographs (can be used with TIFF, JFIF or SPIFF).
  • TWCP_LZW A compression licensed by UNISYS (can be used with TIFF).
  • TWCP_JBIG Intended for bitonal and grayscale document images (can be used with TIFF or SPIFF).
  • TWCP_PNG This compression can only be used if ICAP_IMAGEFILEFORMAT is set to TWFF_PNG.
  • TWCP_RLE4,
  • TWCP_RLE8,
  • TWCP_BITFIELDS These compressions can only be used if ICAP_IMAGEFILEFORMAT is set to TWFF_BMP.
  • TWCP_ZIP Per RFC 1951 (AKA 'Flate' and 'Deflate')
  • TWCP_JPEG2000 Per ISO/IEC 15444