What I do is I have a TImageEnMView and a TImageEnMIO on the form connected to each other. The MView is hidden so users don't see it. When the user scans, I call the Acquire method and nothing more in that method. But I do handle the TImageEnMIO's OnAcquireBitmap event. In that event, I have this code:
var
PersistentBitmap: TBitmap;
begin
PersistentBitmap := TBitmap.Create;
try
ABitmap.CopyToTBitmap( PersistentBitmap );
ImageEnView1.Assign( PersistentBitmap );
ImageEnView1.Fit;
finally
PersistentBitmap.Free;
end;
if FFileHandler.InsertPageAsImage( ImageEnView1, FNumPages ) then
begin
FNumPages := FFileHandler.GetPagesCount;
RewriteStream;
FPageViewed := FNumPages - 1;
end;
procedure TForm1.RewriteStream;
begin
FMemoryStream.Clear;
FFileHandler.WriteStream( FMemoryStream );
end;