Author |
Topic  |
|
zrygo

Armenia
16 Posts |
Posted - Aug 12 2012 : 20:23:14
|
Hey Guys
I scan pages with an ADF scanner, and don't show the Acquisition Dialog,
I want to stop it by using MIO.AcquireClose, but it can not work because the current application window has been locked by the UnVisiable Acquisition Dialog when it's acquiring.
I don't want to show the Acquisition Dialog, but I want to stop the scanner when it's acquiring, Can I ?
Thanks. |
|
fab
   
1310 Posts |
Posted - Aug 17 2012 : 00:43:25
|
Hi, there isn't a way to do it, at the moment. You could try to insert a "ImageEnMView1.MIO.Aborting := true" inside OnAcquireBitmap event, but it could not work on all circumstances. AcquireClose works only with AcquireOpen. |
 |
|
zrygo

Armenia
16 Posts |
Posted - Aug 17 2012 : 09:15:17
|
Sorry to hear that , but I want to stop acquiring in a ButtonClick event, not in the OnAcquireBitmap event.
Anyway, thanks fabrizio.
For my another question, there are several methods to load the image, for example, LoadFromFile(s), LoadFromBuffer, LoadFromStream, and so on, which way is the fastest one?
|
 |
|
xequte
    
39076 Posts |
Posted - Aug 18 2012 : 03:39:39
|
Hi
The difference in speed between the load functions is negligible, but more importantly is not relevant because they serve very different purposes depending on where the image is coming from.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
 |
|
ehkhalid

27 Posts |
Posted - Aug 21 2012 : 03:10:00
|
You can abort the scanning from a button click, i use that for in our scan software "Documalis Free Scanner V2", what you have to do is : Run scan in a thread (I modified a little bit imageenio source to add a Handle paramètre in the acquire function, imageen send image acquired to this handle and not to the main form handle), with this methode, acquirin process is completly independant of the UI interface, so the abort from a button, you add just a property to your thread to active abort, in the button event : thread.abort for exemple, in the Abort function in the thread : imageen.aborting := True;
the other advantage of this technic, is that the acquiring image is very fast and optimal, a thread capture image from scanner, another draw images, and the both are asynchrous ;-).
sorry for my bad english, hope this help. |
 |
|
zrygo

Armenia
16 Posts |
Posted - Aug 27 2012 : 02:37:52
|
thank you for your post, ehkhalid 
It may work but I don't know how to modified the imageenio source,
can you show me the details or just send me a e-mail zrygo@hotmail.com
thanks
|
 |
|
ehkhalid

27 Posts |
Posted - Aug 27 2012 : 03:54:34
|
well, i don't know if i can show imageen source here, so i will show you just what you have to modify.
First thing, we need to redirect scanner response (Bitmap) to our our scan thread and not the main application thread, to do, you need to modify procedure Acquire in the iemio unit, by adding a new param (AHandle : HWND), the new function will be : function Acquire(AHandle : HWND; api: TIEAcquireApi): boolean; in this function, for twain device, imageen call IETW_Acquire function by specifying application main thread handle (IEFindHandle(self)), so juste replace this by AHandle.
for imageen source, that's all modifications to have to do,
in your application : 1. Create a thread class : TScanThread = Class(TThread); private FWinHandle: HWND; fScan : TImageEnMIO; procedure thOnImageAcquired(Sender: TObject; ABitmap: TIEBitmap; var Handled: boolean); protected procedure WndProc(var msg: TMessage); procedure Execute; override; public Constructor Create; Destructor Destroy; override; procedure Abort; end;
3. in the create constructor of thread, we need to allocate a handle : FWinHandle := AllocateHWND(WndProc); fScan := TImageEnMIO.Create(nil); fScan.OnAcquireBitmap := thOnImageAcquired; // assign procedure that will receive bitmaps 4. In the execute procedure : ..... // assigned twain capabilities (color, resolution, ....). fScan.Acquire(FWinHandle,ieaTWain); // here we find the new param for handle. 5. for Abort scannig, the procedure "Abort" declared will be : procedure TScanThread.Abort; begin fscan.Aborting := true; end; 6. you have to implement error event and finished event,
To abort scaning just call the ScanThread.abort;
By using this thread, you will use imageen visual component (imageenmview, imageenview) just to display image, you can use another component if you like, in my case i created my own multithreaded image displayer (TScrollbox + Timage) that is very fast and less consume memory (because i need to display just thumbnail). don't forget to use synchronize procedure if you want display bitmap in your main thread.
you can read this article to see how te receive windows messages in non window application http://delphi.about.com/od/windowsshellapi/l/aa093003b.htm
that's all, hope this help. :) |
 |
|
icsorg
Iran
1 Posts |
Posted - Jul 24 2013 : 12:56:24
|
sorry for my bad english,
I try to Aborting Scanner. for example: 0- My scanner is AV121 (Avision). 1- four pages in the ADF. 2- Start Scan in thread. ==> fScan := TImageEnMIO.Create(nil); 3- Assign ==> fScan.OnAcquireBitmap := thOnImageAcquired; 4- fScan.Acquire(); 5- After one page, call fscan.Aborting := true; 6- After second page scanner wait for 0.5 milisecond 7- and then continue move other pages from ADF scanner without Acquiring any image. 8- but i want to stop scanner after Page one or page two . but not stop. 9- log file: TWain log. Core version 3.1.2 5 9 2010 2013/07/25 12:18:00 AM : CreateProxyWindow 2013/07/25 12:18:00 AM : CreateProxyWindow : created 2013/07/25 12:18:00 AM : IETW_LoadSourceManager 2013/07/25 12:18:00 AM : IETW_LoadSourceManager : Load OK 2013/07/25 12:18:00 AM : IETW_OpenSourceManager 2013/07/25 12:18:00 AM : IETW_OpenSourceManager : Ok 2013/07/25 12:18:00 AM : IETW_OpenSource 2013/07/25 12:18:00 AM : CreateProxyWindow 2013/07/25 12:18:00 AM : CreateProxyWindow : already created 2013/07/25 12:18:00 AM : IETW_LoadSourceManager 2013/07/25 12:18:00 AM : IETW_LoadSourceManager : already loaded 2013/07/25 12:18:00 AM : IETW_OpenSourceManager 2013/07/25 12:18:00 AM : IETW_OpenSourceManager : Ok 2013/07/25 12:18:00 AM : IETW_CloseSourceManager 2013/07/25 12:18:00 AM : IETW_EmptyMessageQueue 2013/07/25 12:18:00 AM : IETW_EmptyMessageQueue : end 2013/07/25 12:18:00 AM : IETW_CloseSourceManager : Ok 2013/07/25 12:18:00 AM : IETW_UnloadSourceManager 2013/07/25 12:18:00 AM : IETW_UnloadSourceManager not Unloaded, for future uses 2013/07/25 12:18:00 AM : DestroyProxyWindow 2013/07/25 12:18:00 AM : DestroyProxyWindow : not destroyed, for future uses 2013/07/25 12:18:01 AM : IETW_OpenSource : Ok 2013/07/25 12:18:01 AM : GetCapability : $1118 2013/07/25 12:18:01 AM : GetCapability : Ok 2013/07/25 12:18:01 AM : GetFix32asDouble 2013/07/25 12:18:01 AM : GetFix32asDouble : ok 2013/07/25 12:18:01 AM : GetCapability : $1119 2013/07/25 12:18:01 AM : GetCapability : Ok 2013/07/25 12:18:01 AM : GetFix32asDouble 2013/07/25 12:18:01 AM : GetFix32asDouble : ok 2013/07/25 12:18:01 AM : IETW_CloseSource 2013/07/25 12:18:02 AM : IETW_CloseSource : Ok 2013/07/25 12:18:02 AM : IETW_CloseSourceManager 2013/07/25 12:18:02 AM : IETW_EmptyMessageQueue 2013/07/25 12:18:02 AM : IETW_EmptyMessageQueue : end 2013/07/25 12:18:02 AM : IETW_CloseSourceManager : Ok 2013/07/25 12:18:02 AM : IETW_UnloadSourceManager 2013/07/25 12:18:02 AM : IETW_UnloadSourceManager not Unloaded, for future uses 2013/07/25 12:18:02 AM : DestroyProxyWindow 2013/07/25 12:18:02 AM : DestroyProxyWindow : not destroyed, for future uses 2013/07/25 12:18:02 AM : IETW_Acquire 2013/07/25 12:18:02 AM : CreateProxyWindow 2013/07/25 12:18:02 AM : CreateProxyWindow : already created 2013/07/25 12:18:02 AM : IETW_LoadSourceManager 2013/07/25 12:18:02 AM : IETW_LoadSourceManager : already loaded 2013/07/25 12:18:02 AM : IETW_OpenSourceManager 2013/07/25 12:18:02 AM : IETW_OpenSourceManager : Ok 2013/07/25 12:18:02 AM : IETW_OpenSource 2013/07/25 12:18:03 AM : IETW_OpenSource : Ok 2013/07/25 12:18:03 AM : IETW_SetCapabilities 2013/07/25 12:18:03 AM : IETW_SetCapabilities : end 2013/07/25 12:18:03 AM : IETW_EnableSource 2013/07/25 12:18:03 AM : IETW_EnableSource : ShowUI=0 hParent=1181184 ModalUI=-1 2013/07/25 12:18:04 AM : IETW_EnableSource : Ok 2013/07/25 12:18:04 AM : IETW_ModalEventLoop 2013/07/25 12:18:04 AM : IETW_ModalEventLoop : event.msg=$C248 2013/07/25 12:18:04 AM : IETW_MessageHook 2013/07/25 12:18:04 AM : IETW_MessageHook : state>=5 2013/07/25 12:18:04 AM : IETW_DS : Source is connected to maximum supported number of applications. 2013/07/25 12:18:04 AM : IETW_MessageHook : event.msg=$0101 2013/07/25 12:18:04 AM : IETW_XferReadyMulti 2013/07/25 12:18:04 AM : IETW_XferReadyMulti : getting another image 2013/07/25 12:18:04 AM : IETW_XferReadyMulti.ImageInfo 2013/07/25 12:18:09 AM : IETW_XferReadyMulti.ImageInfo : end 2013/07/25 12:18:09 AM : IETW_XferReadyMulti : File transfer mode 2013/07/25 12:18:09 AM : IETW_DS : Capability not supported by Source or operation (get,set) is not supported on capability, or capability had dependencies on other capabilities and cannot be operated upon at this time 2013/07/25 12:18:09 AM : IETW_XferReadyMulti : TWRC_XFERDONE 2013/07/25 12:18:09 AM : IETW_XferReadyMulti : getting another image 2013/07/25 12:18:09 AM : IETW_XferReadyMulti, ending : Aborting = true! 2013/07/25 12:18:09 AM : IETW_AbortAllPendingXfers 2013/07/25 12:18:09 AM : IETW_EmptyMessageQueue 2013/07/25 12:18:09 AM : IETW_MessageHook 2013/07/25 12:18:09 AM : IETW_MessageHook : state>=5 2013/07/25 12:18:09 AM : IETW_DS : Source or Source Manager reported an error to the user and handled the error; no application action required. 2013/07/25 12:18:09 AM : IETW_MessageHook : event.msg=$0000 2013/07/25 12:18:09 AM : IETW_MessageHook : MSG_NULL 2013/07/25 12:18:09 AM : IETW_MessageHook : end 2013/07/25 12:18:09 AM : IETW_EmptyMessageQueue : end 2013/07/25 12:18:09 AM : IETW_AbortAllPendingXfers : Ok 2013/07/25 12:18:09 AM : IETW_MessageHook : processed MSG_XFERREADY 2013/07/25 12:18:09 AM : IETW_MessageHook : end 2013/07/25 12:18:09 AM : IETW_ModalEventLoop : end 2013/07/25 12:18:09 AM : IETW_DisableSource 2013/07/25 12:18:20 AM : IETW_EmptyMessageQueue 2013/07/25 12:18:20 AM : IETW_EmptyMessageQueue : end 2013/07/25 12:18:20 AM : IETW_DisableSource : Ok 2013/07/25 12:18:20 AM : IETW_CloseSource 2013/07/25 12:18:21 AM : IETW_CloseSource : Ok 2013/07/25 12:18:21 AM : IETW_CloseSourceManager 2013/07/25 12:18:21 AM : IETW_EmptyMessageQueue 2013/07/25 12:18:21 AM : IETW_EmptyMessageQueue : end 2013/07/25 12:18:21 AM : IETW_CloseSourceManager : Ok 2013/07/25 12:18:21 AM : IETW_UnloadSourceManager 2013/07/25 12:18:21 AM : IETW_UnloadSourceManager not Unloaded, for future uses 2013/07/25 12:18:21 AM : DestroyProxyWindow 2013/07/25 12:18:21 AM : DestroyProxyWindow : not destroyed, for future uses 2013/07/25 12:18:21 AM : IETW_Acquire : end 2013/07/25 12:18:21 AM : DestroyProxyWindow 2013/07/25 12:18:21 AM : DestroyProxyWindow : destroyed 2013/07/25 12:18:21 AM : IETW_UnloadSourceManager 2013/07/25 12:18:21 AM : IETW_UnloadSourceManager : Unload OK
10- my source: unit Test_Aborting_Scan_Unit; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, ieview, hyieutils, iemview, ImageEnView, ImageEnIO,ImageEn,iemio, imscan, ietwain; type Test_Aborting_Scan = class(TThread) private { Private declarations } F_Form:TObject; F_WM_Start, F_WM_Stop, F_WM_Progress, F_WM_Acquired:Integer; F_IsHaveLog:Boolean; F_LogFilename:String; procedure thOnImageAcquired(Sender: TObject; ABitmap: TIEBitmap; var Handled: boolean); procedure FillIn; procedure thOnProgress(Sender: TObject; per: integer); protected procedure Execute; override; public fScan : TImageEnMIO; constructor CreateForAbort(Sender:TObject; WM_Start,WM_Stop,WM_Progress,WM_Acquired:Integer; IsHaveLog:Boolean; LogFilename:String); Destructor Destroy; override; procedure Abort; end;
implementation
procedure Test_Aborting_Scan.Abort; begin fscan.Aborting := true; end;
constructor Test_Aborting_Scan.CreateForAbort(Sender:TObject; WM_Start,WM_Stop,WM_Progress,WM_Acquired:Integer; IsHaveLog:Boolean; LogFilename:String); begin FreeOnTerminate:=True; F_Form:=Sender; F_WM_Start:=WM_Start; F_WM_Stop:=WM_Stop; F_WM_Progress:=WM_Progress; F_WM_Acquired:=WM_Acquired; F_IsHaveLog:=IsHaveLog; F_LogFilename:=LogFilename; inherited Create(False); end;
destructor Test_Aborting_Scan.Destroy; begin inherited; end;
procedure Test_Aborting_Scan.Execute; begin fScan := TImageEnMIO.Create(nil); try if F_IsHaveLog then begin fScan.TwainParams.LogFile:=F_LogFilename; fScan.TwainParams.CompatibilityMode:=True; end; PostMessage(TForm(F_Form).Handle,F_WM_Start,0,0); FillIn; fScan.OnAcquireBitmap := thOnImageAcquired; // assign procedure that will receive bitmaps fScan.OnProgress := thOnProgress; fScan.Acquire(); // here we find the new param for handle. finally fScan.Free; PostMessage(TForm(F_Form).Handle,F_WM_Stop,0,0); end; end;
procedure Test_Aborting_Scan.thOnProgress(Sender: TObject; per: integer); begin SendMessage(TForm(F_Form).Handle,F_WM_Progress,per,per); end;
procedure Test_Aborting_Scan.thOnImageAcquired(Sender: TObject; ABitmap: TIEBitmap; var Handled: boolean); begin SendMessage(TForm(F_Form).Handle,F_WM_Acquired,0,0); Handled:=True; end;
procedure Test_Aborting_Scan.FillIn; begin fScan.TWainParams.VisibleDialog := False; fScan.TWainParams.ProgressIndicators := False; fScan.TWainParams.YResolution.CurrentValue := 100; fScan.TWainParams.XResolution.CurrentValue := 100; fScan.TWainParams.BufferedTransfer := False; end;
end.
------ Thanks.
|
 |
|
|
Topic  |
|
|
|