ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 How does TwainParams.SourceSettings interact with PixelType and other config
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

nachbar

USA
17 Posts

Posted - Oct 18 2023 :  19:49:05  Show Profile  Reply
Hello. I am trying to understand how to use SourceSettings to preserve the scan settings over different runs of my executable.

I am using Fugitsu fi-7460 and fi-7160 scanners.

I am able to use the TwainStore demo to select the scanner configuration (e.g., RGB or Text), and to restore that using SourceSettings.LoadFromFile

The configuration that changes includes the PixelType (RGB or Black and White). However, PixelType.CurrentValue does not seem to change, even when LoadFromFile changes the PixelType from the previously-set (in the scanner) PixelType.

Also, setting PixelType and X and Y Resolution and trying to save the SourceSettings returns an empty stream. The only way I can get SourceSettings to have content appears to be to set ShowSettingsOnly and then call Acquire, as in the demo.

How should SourceSettings interact with PixelType and X and Y resolution? Is that how this is supposed to work? Is there a way to save the scanner settings, including PixelType and resolution, using SourceSettings without showing the scanner dialog? And is there a way to find out if the scanner is scanning in color or black and white when SourceSettings has been used to save and then set the configuration?

Finally, is there a preferred way to save all of the current scanner configuration, including PixelType and resolution set via the API?

Thank you.

Jim Nachbar

James Nachbar

xequte

38610 Posts

Posted - Oct 19 2023 :  01:36:46  Show Profile  Reply
Hi Jim

SourceSettings is filled (by making a twain call for DAT_CUSTOMDSDATA) only when TwainParams.ShowSettingsOnly=TRUE you call Acquire(). Unfortunately it's content is filled by the scanner driver and not parseable by the ImageEn control. The Twain properties it touches also variable by manufacturer, but some such as resolution (https://www.imageen.com/help/TIETwainParams.XResolution.html) and color setting (https://www.imageen.com/help/TIETwainParams.PixelType.html) will be universal.

It cannot be used to load and save settings for UI purposes, only to Acquire with previous settings. If you are looking to maintain Twain state in your own UI, you would need to save the properties yourself, e.g. using: ImageEnView1.IO.AcquireParams.SaveProperties():

http://www.imageen.com/help/TIEAcquireParamsHelper.SaveProperties.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

nachbar

USA
17 Posts

Posted - Oct 19 2023 :  22:41:50  Show Profile  Reply
Thank you. I did some additional testing, and for the benefit of anyone finding this thread in the future (including my future self):

With both my Fujitsu fi-7460 and fi-7160, SourceSettings works to set e.g. PixelType and resolution as used by the scanner, but it does NOT actually change PixelType or XResolution as read via the API, so there is no way to actually determine what the current PixelType or XResolution are if they have been set by SourceSettings

For the both fi-7460 and fi-7160, AcquireSettings works the same as TwainSettings, and the values retrieved via the API do not reflect the PixelType or XResolution when those have been set by SourceSettings.

Further, for both fi-7460 and fi-7160, if you then manually change PixelType, then PixelType as read out via the API as how you set it, and the manually-set PixelType is also how the scanner captures.

BUT, if, after setting PixelType manually, you then try to use SourceSettings for a different setting, SourceSettings no longer works to change PixelType as used by the scanner for scans. In other words, once you manually set PixelType, then the manually set PixelType is what is seen in the API and also how the scanner scans, and you can no longer change PixelType with SourceSettings once you have manually set PixelType.

Restarting the application restores the ability to use SourceSettings again. I do not know if there might be another way to restore that ability short of restarting the application.

Jim Nachbar

James Nachbar
Go to Top of Page

xequte

38610 Posts

Posted - Oct 20 2023 :  02:16:22  Show Profile  Reply
Thanks for the update, Jim,

Did you try calling ImageEnView1.IO.TwainParams.SetDefaultParams() before reloading the source settings?



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

nachbar

USA
17 Posts

Posted - Oct 20 2023 :  08:02:31  Show Profile  Reply
>> Did you try calling ImageEnView1.IO.TwainParams.SetDefaultParams() before reloading the source settings?

No, I had not, but that seems to be the missing factor.

After calling .SetDefaultParams(), not only does loading SourceSettings work again, but it also allows reading PixelType and XResolution to work properly, letting me see via the API what PixelType and XResolution will be used by the scanner to scan.

As expected, calling .SetDefaultParams() does reset VisibleDialog, so you need to be sure to make all your changes to any settings after you call .SetDefaultParams().

Thanks so much for helping me resolve this, and thanks again for all your work on ImageEn! It is an incredibly useful tool, of very high quality.

Jim Nachbar
Go to Top of Page

xequte

38610 Posts

Posted - Oct 20 2023 :  20:08:52  Show Profile  Reply
Thanks Jim

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: