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
 Scanning

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
Darol2k11 Posted - Aug 22 2011 : 01:27:01
Hello,
at the moment i code a small application for batch scanning of documents.
When the user clicks a button my application should:
- Check if the scanner have a autofeeder. If yes it should use it.
- Check if the scanner supports duplex. If yes it should use it.
Then it should scan automaticly scans a Din A5 paper and save it as grayscaled JPEG without compression. When a autofeeder is present and used it should save every scan to a single file. when duplex-scan is enabled it should save every side to a single file.

Is this possible with ImageEn?

Thanks for your help
3   L A T E S T    R E P L I E S    (Newest First)
fab Posted - Aug 22 2011 : 22:35:01
Please remove all TWainParams.Update calls. You have to set parameters just before ImageEnIO1.Acquire, and they don't need Update.
Darol2k11 Posted - Aug 22 2011 : 14:21:20
Hello Fabrizio!
Thanks for the reply.

Now i another question. I've written the following procedure:

procedure Form1.SetScannerOptions(Left, Top, Bottom, Right: Double);
begin
  ImageEnIO1.TWainParams.AcquireFrameEnabled := True;
  ImageEnIO1.TWainParams.AcquireFrameLeft := Left;
  ImageEnIO1.TWainParams.AcquireFrameTop := Top;
  ImageEnIO1.TWainParams.AcquireFrameRight := Bottom;
  ImageEnIO1.TWainParams.AcquireFrameBottom := Right;
  ImageEnIO1.TWainParams.Update;
  ImageEnIO1.TWainParams.VisibleDialog := False;
  ImageEnIO1.TWainParams.PixelType.CurrentValue := 0;
  ImageEnIO1.TWainParams.YResolution.CurrentValue := 300;
  ImageEnIO1.TWainParams.XResolution.CurrentValue := 300;
  ImageEnIO1.TWainParams.BufferedTransfer := True;
  ImageEnIO1.TWainParams.Update;
end;


I call this procedure before every acquire. But there is the following problem:
1.) When i call it with SetScannerOptions(0, 0, 11.69, 8.26) the resulting image has an size of 850x1150 pixel with 100dpi.
But the resulting image should be 2479x3507 with 300dpi.
2.) When acquire again the application freezed and i can only close the application with the delphi ide or the windows task-manager.

Thank for the help.
Greets Daniel
fab Posted - Aug 22 2011 : 02:45:32
Hello,
first let say that not all scanners expose all their features to the twain api, so sometime you have to use the scanner dialog to have all functionalities.

Anyway you can try to use an invisible TImageEnMView an handling the OnAcquireBitmap of the embedded TImageEnMIO (MIO property) component. For example:


var
  page:integer = 0;

procedure TForm1.Button22Click(Sender: TObject);
var
  mview:TImageEnMView;
begin
  mview := TImageEnMView.Create(nil);
  mview.MIO.TWainParams.SelectedSource := 1;
  mview.MIO.TWainParams.DuplexEnabled := true;
  mview.MIO.TWainParams.FeederEnabled := true;
  mview.MIO.TWainParams.VisibleDialog := false;
  mview.MIO.OnAcquireBitmap := AcquireBitmap;
  mview.MIO.Acquire();
  mview.Free();
end;

procedure TForm1.AcquireBitmap(Sender: TObject; ABitmap: TIEBitmap; var Handled: boolean);
var
  io:TImageEnIO;
begin
  io := TImageEnIO.CreateFromBitmap(ABitmap);
  try
    io.Params.JPEG_ColorSpace := ioJPEG_GRAYLEV;
    io.Params.JPEG_Quality := 100;
    io.SaveToFile(Format('page%d.jpg', [page]));
    inc(page);
  finally
    io.Free();
  end;
end;


Note that jpeg is lossy format, even if you set JPEG_Quality=100.
You may want to change SelectedSource with another index or allow user to select the device using a dialog.