Pregunta

I am using TDelphiTwain component for scanning. When i start scanning from feeder, all scanning performed assynchronously and event OnTwainAcquire triggered when new image available for processing. But i can not find how to check that scanning of all douments already finished. When feeder tray is empty, then scanning stops and if i put new papers to the feeder it do not process it. So i need to know that it is finished and i can process received images. I can check that feeder is empty, but i can easy miss (with my check) the moment when tray was empty, so app will think that new images are coming, but they don't. I supposed there should be kind of events for such task (StartSession/StopSession), but i can't find it.

in the code it looks like this:

procedure TFormDemo.FormShow(Sender: TObject);
begin
  Twain := TTwainScanner.Create;
  Twain.OnTwainAcquire := Acquire;
  Twain.Source[SelectedDevice].SetFeederEnabled(True);
  Twain.Source[SelectedDevice].Enabled := True; // start
end;

procedure TFormDemo.Acquire(Sender: TObject; const Index: Integer;
  Bitmap: TBitmap; var Cancel: Boolean);
begin
  // some processing
  Cancel := False;
end;

I also catch OnAcquireProgress event but it is progress of current image scanning and it doesn't help to know when scanning stopped.

UPDATE: I almost found solution. When TTwainSource finishes processing of TWAIN events it sets ENABLED=false for TTwainsource. Unfortunately inside of OnTwainAcquire it is still True, it became False later and there is no event where i can check it. Like workaround i can check it by timer.

¿Fue útil?

Solución

I used DelphiTwain from here http://www.kluug.net/delphitwain.php Author agreed to add new event, so with updated version of the library problem was solved.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top