Quantcast
Channel: Saraff.Twain.NET
Viewing all 419 articles
Browse latest View live

New Post: Scan automatically ?


New Post: InvalidCastException when retrieving SupportedCaps capability

$
0
0
I'm using Saraff version, 1.0.20.517, with an HP Scanjet 8200 with official driver.

I am iterating on capabilities in order to retrieve the supported ones. In order to test if it is supporte I'm using:
twain32.IsCapSupported(TwCap.SupportedCaps)
I am getting:
InvalidCastException: Cannot cast from Saraff.Twain.__TwArray to Saraff.Twain.TwOneValue.
Is this expected?

New Post: InvalidCastException when retrieving SupportedCaps capability

$
0
0
Hello, jruizaranguren.
According to the specification, the operation DG_CONTROL / DAT_CAPABILITY / MSG_QUERYSUPPORT must return the container of a TWON_ONEVALUE type.

DG_CONTROL / DAT_CAPABILITY / MSG_QUERYSUPPORT

Description

Returns the Source’s support status of this capability.

Application

Set the pCapability fields as follows:
pCapability->Cap = the CAP_xxxx or ACAP_xxxx or ICAP_xxxx identifier
pCapability->ConType = TWON_ONEVALUE
pCapability->hContainer = NULL
The Source will allocate the memory for the necessary container structure but the application must
free it when the operation is complete and the application no longer needs to maintain the
information.
Use MSG_QUERYSUPPORT:
  • To check the whether the Source supports a particular operation on the capability.
    This operation may fail for a low memory condition. Either recover from a TWCC_LOWMEMORY
    failure by freeing memory for the Source to use so it can continue, or terminating the acquisition
    and notifying the user of the low memory problem.

Source

Fill the fields in pCapability as follows:
pCapability->ConType = TWON_ONEVALUE
pCapability->hContainer = TW_HANDLE referencing a container of type TW_ONEVALUE.
Fill the fields in TW_ONVALUE as follows:
  1. ItemType = TWTW_INT32;
  2. Item = Bit pattern representing the set of operation that are supported by the Data Source on
    this capability (TWQC_GET, TWQC_SET, TWQC_GETCURRENT, TWQC_GETDEFAULT,
    TWQC_RESET, TWQC_SETCONSTRAINT, TWQC_CONSTRAINABLE);
TWAIN 2.2 Specification 7-25


Moreover, in the CAP_SUPPORTEDCAPS description specified that the MSG_QUERYSUPPORT operation must return the TW_ONEVALUE.

CAP_SUPPORTEDCAPS

Description

Containers

  • MSG_GET: TW_ARRAY
  • MSG_GETCURRENT: TW_ARRAY
  • MSG_GETDEFAULT: TW_ARRAY
  • MSG_SET: Not Allowed
  • MSG_SETCONSTRAINT: Not Allowed
  • MSG_RESET: Not Allowed
  • MSG_QUERYSUPPORT: TW_ONEVALUE
TWAIN 2.2 Specification 10-91


Thus, the problem in the HP Scanjet 8200 scanner driver.

New Post: InvalidCastException when retrieving SupportedCaps capability

$
0
0
Thank you very much for the answer (and awesome library).

New Post: MessageBox doesn't show in the AcquireCompleted event

$
0
0
Hello guys!

I does not understand what is happening with my code .. If i put MessageBox out of AcquireCompleted event it work's!

I'm doing something like this:

class Scanner{
    public Scanner(){
               _twain.AcquireCompleted += new EventHandler(complete);
    }

    private void complete(object sender, EventArgs e){
             if (
            MessageBox.Show(
            "Successful!", "Information",
            MessageBoxButtons.OK,
            MessageBoxIcon.Information,
            MessageBoxDefaultButton.Button1) == DialogResult.OK);
    }
}

Thank's everybody!

Peter.

New Post: SetCap TwCap.ICompression BadValue setting TwCompression.Lzw

$
0
0
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.

New Post: MessageBox doesn't show in the AcquireCompleted event

$
0
0
Hello, pogs17.
Try process the Twain32.AcquireError event.

New Post: SetCap TwCap.ICompression BadValue setting TwCompression.Lzw

$
0
0
Hello, GuyTraveler.
Invoke the _twain.Capabilities.Compression.Get() method that get supported values.

New Post: The library maintains a waiting state even after the call of 'AcquireCompleted'

$
0
0
Hello everyone.
I'm developing a tool in WPF and I have encountered a problem that occurs when you use a scanner with ADF . I manually set the settings and when calling the ' AcquireCompleted ' I have left the program blocked for hours .
The same code used with a flatbed scanner works great .

How can I solve this problem?
Thank you.
        private void _TwainCompleted(object sender, EventArgs e)
        {
            if (!this._twain32.ShowUI)
            {
                this._twain32.CloseDataSource();
            }
        }

        public void cmd_Scan()
        {
            try
            {
                this._twain32.CloseDataSource();
                this._twain32.ShowUI = sessione.config.isUI;

                if (this._twain32.IsTwain2Supported)
                    this._twain32.IsTwain2Enable = true;

                if (!this._twain32.ShowUI)
                {
                    this._twain32.OpenDataSource();

                    this._twain32.DisableAfterAcquire = false;

                    // Imposto la risoluzione X
                    if ((this._twain32.Capabilities.XResolution.IsSupported() & TwQC.Set) != 0)
                        this._twain32.Capabilities.XResolution.Set(sessione.config.resolution);

                    // Imposto la risoluzione Y
                    if ((this._twain32.Capabilities.YResolution.IsSupported() & TwQC.Set) != 0)
                        this._twain32.Capabilities.YResolution.Set(sessione.config.resolution);

                    // Imposto B/W Gray Color
                    if ((this._twain32.Capabilities.PixelType.IsSupported() & TwQC.Set) != 0)
                        this._twain32.Capabilities.PixelType.Set(sessione.config.pixelType);

                    // Imposto l'autore
                    if ((this._twain32.Capabilities.Author.IsSupported() & TwQC.Set) != 0)
                        this._twain32.Capabilities.Author.Set(AppUtils.getAppName().PadRight(128, '\0'));

                    // Verifico se è supportato il duplex
                    if ((this._twain32.Capabilities.Duplex.IsSupported() & TwQC.GetCurrent) != 0)
                    {
                        TwDX duplexMode = this._twain32.Capabilities.Duplex.GetCurrent();
                        if (duplexMode != TwDX.None)
                        {
                            // Abilito il caricatore.
                            if ((this._twain32.Capabilities.FeederEnabled.IsSupported() & TwQC.Set) != 0)
                            {
                                bool isFeederLoaded = true;
                                this._twain32.Capabilities.FeederEnabled.Set(isFeederLoaded);

                                // Controllo la presenza di documenti nel caricatore. Se non ci sono fogli
                                // disattivo il caricatore.
                                if ((this._twain32.Capabilities.FeederLoaded.IsSupported() & TwQC.GetCurrent) != 0)
                                    isFeederLoaded = this._twain32.Capabilities.FeederLoaded.GetCurrent();

                                this._twain32.Capabilities.FeederEnabled.Set(isFeederLoaded);
                            }

                            //if ((this._twain32.Capabilities.AutoFeed.IsSupported() & TwQC.Set) != 0)
                            //    this._twain32.Capabilities.AutoFeed.Set(true);

                            if ((this._twain32.Capabilities.XferCount.IsSupported() & TwQC.Set) != 0)
                                this._twain32.Capabilities.XferCount.Set(-1);

                            if ((this._twain32.Capabilities.DuplexEnabled.IsSupported() & TwQC.Set) != 0)
                                this._twain32.Capabilities.DuplexEnabled.Set(ckFR);
                        }
                    }
                }

                this._twain32.Acquire();
            }
            catch (Exception ex)
            {
                UC.MBException(ex);
            }
        }

New Post: The library maintains a waiting state even after the call of 'AcquireCompleted'

$
0
0
Hello, alevin.
I don't quite understand the purpose of this code:
if (!this._twain32.ShowUI)
            {
                this._twain32.CloseDataSource();
            }
if (!this._twain32.ShowUI)
                {
                    this._twain32.OpenDataSource();

                    this._twain32.DisableAfterAcquire = false;
And this code at all does not make sense, because it is necessary to perform before a Twain32.OpenDSM(). Use TWAIN 2.x
if (this._twain32.IsTwain2Supported)
                    this._twain32.IsTwain2Enable = true;

New Post: The library maintains a waiting state even after the call of 'AcquireCompleted'

$
0
0
To speed I have not included all the code for my UserControl .
The OpenDSM() is called just created the UserControl .

The OpenDataSource() is called to set the configuration parameters; without the program breaks .

I also need to call the CloseDataSource( ) or I jump after the settings Acquire( ) . For this reason I call her when I finished scanning.

New Post: The library maintains a waiting state even after the call of 'AcquireCompleted'

$
0
0
Hello, alevin.
I will clarify my question.
What do you expect from this line of code.
this._twain32.DisableAfterAcquire = false;

New Post: The library maintains a waiting state even after the call of 'AcquireCompleted'

$
0
0
This line should enable / disable the caller after the acquisition . I tried to remove it , setting it to true to false , but the result does not change .

New Post: The library maintains a waiting state even after the call of 'AcquireCompleted'

$
0
0
Hello, alevin.
I'm afraid you misunderstood the purpose of a Twain32.DisableAfterAcquire property. I suggest you read the TWAIN specification.

New Post: MessageBox doesn't show in the AcquireCompleted event

$
0
0
Hello, SARAFF.

Ok, but this event is useful when an error occurs.

I want to show a message when the scan process is finished. When i used 'MessageBox.Show' out of the event 'AcquireCompleted' it work's! Instead no ..

Thanks for your help!

New Post: SetCap TwCap.ICompression BadValue setting TwCompression.Lzw

$
0
0
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.

New Post: MessageBox doesn't show in the AcquireCompleted event

$
0
0
Hello, pogs17.
Probably, during the Acquire process occurs exception. In this case, instead the Twain32.AcquireCompleted event occurs the Twain32.AcquireError event. Check a ConditionCode property and inner exception (if it set) and him a StackTrace.

New Post: SetCap TwCap.ICompression BadValue setting TwCompression.Lzw

$
0
0
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

New Post: InvalidCastException when retrieving SupportedCaps capability

$
0
0
I received the same error on a Kyocera TASKalfa 4551ci so I decided to review the issue. Both HP Scanjet 8200 and Kyocera TASKalfa 4551ci are not Twain 2 drivers, so the 2.2 spec does not apply here.

Previous versions of the specification (at least 1.9) do not mention the MSG_QUERYSUPPORT: TW_ONEVALUE.

SupportedCaps can be retrieved using the Twacker tool for both scanners without major problems, so I guess there is an alterante way to retrieve the capabilities that works:
ItemType=TWTY_UINT16
ItemList=CAP_XFERCOUNT
ItemList=CAP_SUPPORTEDCAPS
ItemList=CAP_UICONTROLLABLE
ItemList=ICAP_COMPRESSION
ItemList=ICAP_PLANARCHUNKY
ItemList=ICAP_PHYSICALHEIGHT
ItemList=ICAP_PHYSICALWIDTH
ItemList=ICAP_PIXELFLAVOR
ItemList=ICAP_BITDEPTH
ItemList=ICAP_BITORDER
ItemList=ICAP_PIXELTYPE
ItemList=ICAP_UNITS
ItemList=ICAP_XFERMECH
ItemList=ICAP_XRESOLUTION
ItemList=ICAP_YRESOLUTION
ItemList=ICAP_IMAGEFILEFORMAT
ItemList=CAP_INDICATORS
ItemList=CAP_ENABLEDSUIONLY
ItemList=CAP_DEVICEONLINE
ItemList=ICAP_XNATIVERESOLUTION
ItemList=ICAP_YNATIVERESOLUTION
ItemList=ICAP_BRIGHTNESS
ItemList=ICAP_CONTRAST
ItemList=ICAP_XSCALING
ItemList=ICAP_YSCALING
ItemList=ICAP_THRESHOLD
ItemList=CAP_FEEDERENABLED
ItemList=CAP_FEEDERLOADED
ItemList=CAP_AUTOFEED
I get the same structure for the Virtual Twain 2.2 scanner.

New Post: InvalidCastException when retrieving SupportedCaps capability

$
0
0
Hello, jruizaranguren.
I think you mistaken, because a DG_CONTROL / DAT_CAPABILITY / MSG_QUERYSUPPORT operation must return a bit flags value of a TWQC_xxxx.
Bellow you can see result of DG_CONTROL / DAT_CAPABILITY / MSG_QUERYSUPPORT (for CAP_SUPPORTEDCAPS) operation for a "TWAIN FreeImage Software Scanner" (from a Twacker).
ItemType=TWTY_INT32
Item=TWQC_GET |TWQC_GETDEFAULT |TWQC_GETCURRENT 

DG_CONTROL / DAT_CAPABILITY / MSG_QUERYSUPPORT

Description

Returns the Source’s support status of this capability.

Application

Set the pCapability fields as follows:
pCapability->Cap = the CAP_xxxx or ACAP_xxxx or ICAP_xxxx identifier
pCapability->ConType = TWON_ONEVALUE
pCapability->hContainer = NULL
The Source will allocate the memory for the necessary container structure but the application
must free it when the operation is complete and the application no longer needs to maintain the
information.
Use MSG_QUERYSUPPORT:
  • To check the whether the Source supports a particular operation on the capability.
This operation may fail for a low memory condition. Either recover from a
TWCC_LOWMEMORY failure by freeing memory for the Source to use so it can continue, or
terminating the acquisition and notifying the user of the low memory problem.

Source

Fill the fields in pCapability as follows:
pCapability->ConType = TWON_ONEVALUE
pCapability->hContainer = TW_HANDLE referencing a container of type TW_ONEVALUE.
TWAIN 1.9 Specification 7-151
Viewing all 419 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>