Lazarus

Programming => General => Topic started by: polpero on May 17, 2019, 10:34:52 pm

Title: Call to Delphi Twain
Post by: polpero on May 17, 2019, 10:34:52 pm
Hi

I had a small program using  Kluug's Delphi Twain that worked in Laz 1.8 and wont call the Twain Acquire window anymore in 2.02... It may have nothing to do with Lazarus but rather with Windows 10 although the Delphi 7 version works fine...

has anyone else swam in those waters?
Title: Re: Call to Delphi Twain
Post by: jamie on May 17, 2019, 10:43:03 pm
I just recently put in a twain UNIT I got somewhere from the net using 2.0.2 in a project, it seems to work for me..

Are you sure you didn't install the 64 bit laz ? there may be no 64 bit drivers installed.
Title: Re: Call to Delphi Twain
Post by: polpero on May 18, 2019, 02:25:43 am
Thanks Jamie

you were right
i was stuck with an old copy of attempts to run it in 64bits
and a few major events weren't assigned...

my mistake
Title: Re: Call to Delphi Twain
Post by: jamie on May 19, 2019, 08:05:41 pm
I don't know if this is just coincidence or what ever, but I just tried out one of my other apps that has Twain support for it
, did a complete recompile because I was modifying some buttons and noticed my twain does not work anymore.

  I don't have any supported devices installed in this PC but the default test device should appear and it does not.

 The only other thing I can think of is I just had a windows update prior to doing this..

  it fails doing the EnumerateDeviceList, the dummy twain isn't coming back..

 I suppose I could install a scanner to test this..
Title: Re: Call to Delphi Twain
Post by: polpero on May 20, 2019, 01:17:34 am
Strange...

My program is up and running fine... using the Kluug's version:

http://www.kluug.net/delphitwain.php

maybe you could check it?


Title: Re: Call to Delphi Twain
Post by: jamie on May 20, 2019, 03:41:57 am
The code I am using is just about the same.. it worked before but I just had a windows update and it must of removed
or messed up the fake device that normally gets installed..

 It all works if I skip the check point when it enumerates devices, the dialog will comeup etc...

 but it looks like I now have no devices that are showing since the windows update.

 I'll have to install a flatbed scanner to see what happens..
 
 Thanks.
Title: Re: Call to Delphi Twain
Post by: CM630 on September 17, 2020, 01:18:44 pm
There is some bug in this, but I cannot fix it- the Product Name are truncated.
There is sth. wrong in Structure.ProductName from DelphiTwain.pas.
Title: Re: Call to Delphi Twain
Post by: rvk on September 17, 2020, 02:15:25 pm
There is some bug in this, but I cannot fix it- the Product Name are truncated.
There is sth. wrong in Structure.ProductName from DelphiTwain.pas.
Are you sure that's a bug?
From the Twain documentation:
Code: Pascal  [Select][+][-]
  1. typedef unsigned char TW_STR32[34], FAR *pTW_STR32;
So ProductName (and Manufacturer and ProductFamily) are all limited to 34 characters.

On how many characters is it truncated for you??
Title: Re: Call to Delphi Twain
Post by: CM630 on September 17, 2020, 07:44:06 pm
On how many characters is it truncated for you??
The image answers better:

Title: Re: Call to Delphi Twain
Post by: rvk on September 17, 2020, 08:29:53 pm
On how many characters is it truncated for you??
The image answers better:
Twain standard 2.2 is 34 characters.
https://www.twain.org/wp-content/uploads/2016/03/TWAIN-2.2-Spec.pdf
and the latest 2.4 too
https://www.twain.org/wp-content/uploads/2017/03/TWAIN-2.4-Specification.pdf

The TW- in your image seems to be truncated at 27. (Edit: not truncated but has version and bitness after it)
The WIA seems to be correctly truncated at 34.

Not sure if those other selection screens really use the Twain standard.

Edit: Actually... looking at the other Select source image... they are truncated TOO !!!!
But they have a driver version after them and an indication for 32 bit (32-32)
So all Select source samples are the same for the ProductName.

The Select source screen itself comes from the Twain driver so I'm not sure which flags should be added to get the version and (32-32) to show for you too.

Edit #2: Again. Last correction.
For DelphiTwain the Select Source is custom.
It is called TDelphiTwain.CustomSelectSource()
In there you can add the version-number and bitness.
I'm not sure how to call the standard Select Source from Twain itself (but there must be a way).
Title: Re: Call to Delphi Twain
Post by: jamie on September 17, 2020, 11:42:02 pm
I got my app to work with DelphiTwain. I guess I could look at it to see what it was I did..
Title: Re: Call to Delphi Twain
Post by: CM630 on September 18, 2020, 07:58:17 am

Edit #2: Again. Last correction.
For DelphiTwain the Select Source is custom.
It is called TDelphiTwain.CustomSelectSource()
In there you can add the version-number and bitness.
I'm not sure how to call the standard Select Source from Twain itself (but there must be a way).
Thanks, I will try to do sth in that diretion.

Quote from: jamie
I got my app to work with DelphiTwain. I guess I could look at it to see what it was I did..
No need to check, software itself works, only the indicated value in the selec twain dialog are odd.
Title: Re: Call to Delphi Twain
Post by: jamie on September 18, 2020, 01:24:59 pm
U don't need to use the dialog to select the device.
The list can be gotten from the properties. From there u can display it as u wish.
Title: Re: Call to Delphi Twain
Post by: rvk on September 18, 2020, 01:36:32 pm
U don't need to use the dialog to select the device.
The list can be gotten from the properties. From there u can display it as u wish.
Like DelphiTwain itself does with TDelphiTwain.CustomSelectSource()  :D
Title: Re: Call to Delphi Twain
Post by: jamie on September 18, 2020, 10:40:03 pm
As we were talking about this last night, I was testing a page scan into an app I have and it kept scanning a blank image but at the size I cropped.

 The moral of the story is, don't believe what your scanner tells you it has already sitting on the surface because it could be showing you the last image it scanned.

 Its always a good idea to make sure you actually have a document sitting on the scan surface because the scanners can lie to you!  >:(
Title: Re: Call to Delphi Twain
Post by: rvk on September 18, 2020, 10:59:35 pm
Its always a good idea to make sure you actually have a document sitting on the scan surface because the scanners can lie to you!  >:(
Haha. The preview scan? Yes, that one gets only refreshed when you select a new preview.

I usually have the scan on full a4+ size (without preview) and crop it afterwards to a4 (directly to pdf).

I did change DelphiTwain slightly to also pass back the resolution scanned to set that in the bmp. Somehow that info didn't get into the bmp/timage that I got back.
TinyPortal © 2005-2018