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
 Scan of multiple pages with TIFF file

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
John Posted - Feb 14 2014 : 17:00:05
Hello

Currently, I use the following eight lines of code to a) acquire a scanned image, b) place the image into an ImageEnView component and then c) load the image to both an ImageEnMView component and also into a tiff handler.

if ImageEnView1.IO.Acquire = True then
begin
ImageEnView1.SetIEBitmap( ImageEnMView1.AppendImage, ImageEnView1.IEBitmap );
tempImageCount := ImageEnMView1.ImageCount;

tempTiffHandler.InsertPageAsImage(ImageEnView1, tempImageCount - 1);
tempMemoryStream.Clear;
tempTiffHandler.WriteStream(tempMemoryStream);
end

What I wish to do is scan multiple pages at once into the ImageEnMView via ImageEnMView1.MIO.Acquire while utilizing an automatic sheet feeder. I also need to be able to load the individual scanned pages into the tiff handler. Both the forum and Mr. Miller's text reference an OnAfterAcquireBitmap event. Based on the event's name, I would anticipate that it would provide access to each newly scanned image as it is created and this is where I could capture the image and load it into the tempTiffHandler.


Also, I would suspect that this phantom event would allow me to avoid having to individually place each newly scanned image into the ImageEnView component prior to loading the image into the tempTIFFHandler.

The problem is that I can not find the OnAFterAcquireBitmap event associated with the ImageENMView component.

Can anyone please explain to me what I am missing?

TIA

John

4   L A T E S T    R E P L I E S    (Newest First)
Elemental Posted - Mar 27 2014 : 09:17:16
I, too, discarded the code involving TIETIFFHandler and instead show the TImageEnMView to my users. I still have a TImagEnMIO component "attached" to the visible TImageEnMView component, and when I call Acquire, I only handle the OnAcquireBitmap event, incrementing FNumPages if not Aborting.

"Roj"
John Posted - Mar 27 2014 : 08:44:50
Elemental

I appreciate your reply.

a)
I did find that the following change was required to your code.

var
PersistentBitmap: TBitmap;
begin
PersistentBitmap := TBitmap.Create;
try
ABitmap.CopyToTBitmap( PersistentBitmap );
ImageEnView1.Assign( PersistentBitmap );
ImageEnView1.Fit;
finally
PersistentBitmap.Free;
end;

FNumPages := FFileHandler.GetPagesCount;

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;

b)
In my scenario, the ImageEnMView component is visible to the user and they load an image into a ImageEnView component using ImageEnMView.OnSelect idx. The problem with your solution in my scenario is that when scanning multiple pages, the ImageEnMView.OnSelect idx values are reset after the pages are scanned. The last page scanned become idx 0 and the idx increments from there. This means the idx of the ImageEnMView and TiffHander no longer corrolate.

My solution is to automatically save the newly scanned file and then rebuild the TiffHandler within a button.OnClick event, see code below.

ImageEnMIO1.Acquire;

SpeedButtonSaveClick(Self);
tempTiffHandler.FreeData;
tempMemoryStream.Clear;
tempTiffHandler.ReadFile(tempScannedImageDataPath + tempScannedImageFileName);
tempTiffHandler.WriteStream(tempMemoryStream);

ImageEnMView1ImageSelect(Self, ImageEnMView1.ImageCount - 1);

I would still prefer to capture the individual pages in the ImageEnMView.OnAfterEvent and have them correlate with the TiffHandler so that I would not have to save the file after scanning. However, I have been unsuccessful to date in this endeavour.

TIA

John
Elemental Posted - Mar 21 2014 : 11:18:35
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;

w2m Posted - Feb 14 2014 : 17:15:06
There is no OnAfterAquireBitmap event as OnAcquireBitmap is called after acquiring a bitmap.

You only have OnAfterEvent and OnAllDisplayed events to work with.

procedure TForm1.ImageEnMView1AfterEvent(Sender: TObject; Event: TIEAfterEvent);
{Occurs immediately after ImageEn has processed an event.  This may work but I have not tried it.}
begin
  if Event = ieaePaint then
  begin

  end;
end;

procedure TForm1.ImageEnMView1AllDisplayed(Sender: TObject);
{Occurs when all images have been loaded and displayed.  This usally executes after using FillFromdirectory...}
begin

end;


William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html