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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 FillListWithSources includes unwanted info

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Homer Posted - Jan 04 2022 : 15:12:21
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 );
...

8   L A T E S T    R E P L I E S    (Newest First)
Homer Posted - Jan 09 2022 : 03:58:55
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.
xequte Posted - Jan 08 2022 : 16:33:22
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
Homer Posted - Jan 07 2022 : 13:23:59
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.
Homer Posted - Jan 07 2022 : 00:46:16
Thanks. I'll do a speed test between this and the method I'm using. It's pretty quick.
xequte Posted - Jan 07 2022 : 00:28:55
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
Homer Posted - Jan 05 2022 : 15:33:49
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;
Homer Posted - Jan 05 2022 : 12:33:58
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?
xequte Posted - Jan 05 2022 : 04:47:43
Please see:

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


Nigel
Xequte Software
www.imageen.com