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
 Scanning
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Darol2k11

2 Posts

Posted - Aug 22 2011 :  01:27:01  Show Profile  Reply
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

fab

1310 Posts

Posted - Aug 22 2011 :  02:45:32  Show Profile  Reply
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.


Go to Top of Page

Darol2k11

2 Posts

Posted - Aug 22 2011 :  14:21:20  Show Profile  Reply
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
Go to Top of Page

fab

1310 Posts

Posted - Aug 22 2011 :  22:35:01  Show Profile  Reply
Please remove all TWainParams.Update calls. You have to set parameters just before ImageEnIO1.Acquire, and they don't need Update.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: