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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Saving files from a feeder scan
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Tod

9 Posts

Posted - Feb 29 2012 :  14:21:41  Show Profile  Reply
Hi,

Do you have an example of the proper way to save out the images created from a twain feeder scan? My guess is that one must do it in either the OnAquireBitmap or OnAfterAquireBitmap event. I'd like to save the images out as JPGs as soon as they are scanned through the feeder. None of the examples save the files.

Thanks

fab

1310 Posts

Posted - Feb 29 2012 :  14:42:13  Show Profile  Reply
Hi,
there are two ways.
1) the obvious way using TImageEnMView: acquire using Acquire then save using ImageEnmView.MIO.SaveToFile()
Of course you can still save each page as a separated jpeg, using ImageEnMView.GetImageToFile()

2) using an TImageEnMIO (without TImageEnMView) and handling OnAcquireBitmap. Example:

var
  mio:TImageEnMIO;
begin
  mio := TImageEnMIO.Create(nil);
  try
    mio.OnAcquireBitmap := AcquireBitmap;
    mio.SelectAcquireSource();
    mio.Acquire();
  finally
    mio.Free();
  end;
end;

var idx:integer = 0;

procedure TForm1.AcquireBitmap(Sender: TObject; ABitmap: TIEBitmap; var Handled: boolean);
begin
  ABitmap.Write(Format('c:\page%d.jpg', [idx]));
  inc(idx);
  Handled := true;
end;
Go to Top of Page

Tod

9 Posts

Posted - Feb 29 2012 :  14:49:03  Show Profile  Reply
Perfect,

My guess is that this won't update the ImageFilename[] property for each image. Would it be proper to just call a FillFromDirectory after the scan to populate these values?

Thanks
Go to Top of Page

fab

1310 Posts

Posted - Feb 29 2012 :  14:58:50  Show Profile  Reply
ImageFileName[] is useful to display images stored in existing files, so, yes you have to save them and then call FillFromDirectory (or set ImageFileName[] manually).

Of course you can still set ImageFileName inside OnAcquireBitmap:

procedure TForm1.ButtonClick(Sender: TObject);
begin
  ImageEnMView1.MIO.OnAcquireBitmap := AcquireBitmap;
  ImageEnMView1.MIO.SelectAcquireSource();
  ImageEnMView1.MIO.Acquire();
end;

procedure TForm1.AcquireBitmap(Sender: TObject; ABitmap: TIEBitmap; var Handled: boolean);
var
  idx:integer;
  filename:string;
begin
  idx := ImageEnMView1.AppendImage();
  filename := Format('c:\page%d.jpg', [idx]);
  ABitmap.Write(filename);
  ImageEnMView1.ImageFileName[idx] := filename;
  Handled := true;
end;
Go to Top of Page

Tod

9 Posts

Posted - Feb 29 2012 :  15:21:05  Show Profile  Reply
Absolutely perfect :-)

Thanks Fabrizio
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: