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
 FillListWithSources includes unwanted info
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Homer

USA
70 Posts

Posted - Jan 04 2022 :  15:12:21  Show Profile  Reply
How can I eliminate the extra characters after the device name? Note the characters circled in red.





with frmMain.ImageEnMView1.MIO do
  begin
    {DEVICES INTO CBO LIST}
    AcquireParams.FillListWithSources( cboSource.Items );
...

xequte

38180 Posts

Posted - Jan 05 2022 :  04:47:43  Show Profile  Reply
Please see:

https://www.imageen.com/help/StrToAcquireSource.html


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

Homer

USA
70 Posts

Posted - Jan 05 2022 :  12:33:58  Show Profile  Reply
I can't figure out how to use that function. The help item does not give an example, and it is not used in the AllAcquire demo. Can you please provide a line or two of code?
Go to Top of Page

Homer

USA
70 Posts

Posted - Jan 05 2022 :  15:33:49  Show Profile  Reply
I fixed it myself:

{DEVICES INTO CBO LIST}
    sl := TStringList.Create;
    try
    cboSource.Clear;
    AcquireParams.FillListWithSources(sl);
    for i := 0 to sl.Count - 1 do
      cboSource.Items.Add(Copy(sl[i],1,Pos('|',sl[i])-1));
    finally
      FreeAndNil(sl);
    end;
Go to Top of Page

xequte

38180 Posts

Posted - Jan 07 2022 :  00:28:55  Show Profile  Reply
Sorry, I just recalled, you can also use:

ImageEnMView1.MIO.AcquireParams.FillListWithSources( cboSource.Items, [], True );

https://www.imageen.com/help/TIEAcquireParams.FillListWithSources.html


Here is an example for StrToAcquireSource()

// Save the current acquisition source to the registry
procedure TMainForm.FormClose(Sender: TObject; var Action: TCloseAction);
var
  sDevice : string;
begin
  ...
  // Read the selected device
  sDevice := AcquireSourceToStr( ImageEnMView1.MIO.SelectedAcquireSource );
  WRegistry.WriteString( 'SelectedAcquireSource', sDevice );
  ...
end;

// Read the current acquisition source to the registry
procedure TMainForm.FormShow(Sender: TObject);
var
  sDevice : string;
  ADevice : TIEAcquireSource;
begin
  ...
  // Restore the device selection
  sDevice := WRegistry.ReadString( 'SelectedAcquireSource', '' );
  if sDevice <> '' then
  begin
    ADevice := StrToAcquireSource( sDevice );
    ImageEnView1.IO.SetAcquireSource( ADevice.Api, ADevice.Location );
    Label1.Caption := 'Scanner: ' + ADevice.Name;
  end;
  ...
end;


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

Homer

USA
70 Posts

Posted - Jan 07 2022 :  00:46:16  Show Profile  Reply
Thanks. I'll do a speed test between this and the method I'm using. It's pretty quick.
Go to Top of Page

Homer

USA
70 Posts

Posted - Jan 07 2022 :  13:23:59  Show Profile  Reply
I did a crude speed test comparing this
for i := 0 to frmMain.ImageEnView1.IO.TwainParams.SourceCount - 1 do
    cboSource.Items.Add( String( frmMain.ImageEnView1.IO.TwainParams.SourceName[i] ));
To this
frmMain.ImageEnMView1.MIO.AcquireParams.FillListWithSources( cboSource.Items, [], True );

The result were interesting. The loop was consistently sub-second every time. Using AcquireParams was just over 2 seconds the first time it was used, and then sub-second thereafter, as long as the application had not been restarted. Restarting the app put it back to the 2 second mark the first time, and faster thereafter.

Since this project is auxiliary to (and called by) a much larger project, it is likely that the end user will open this app, and scan one document. Therefore, I'm sticking with the loop. It is fast the very first time, and all subsequent times.

Thanks for offering an alternative. It's nice to know there is more than one way to skin this cat.
Go to Top of Page

xequte

38180 Posts

Posted - Jan 08 2022 :  16:33:22  Show Profile  Reply
Hi

The first method is only getting Twain devices, whereas the second also checks and initializes WIA, WPD, etc.

A more accurate comparison would be:

frmMain.ImageEnMView1.MIO.AcquireParams.FillListWithSources( cboSource.Items, [ieaTwain], True );

Which should give the same speed as iterating TwainParams.SourceNames


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

Homer

USA
70 Posts

Posted - Jan 09 2022 :  03:58:55  Show Profile  Reply
That makes perfect scene. Thanks for pointing that out. I'll probably leave the loop in since I'm only interested in the Twain drivers. At least I think that's so. If I need WIA in the future, now I know how.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: