Here is my code. Can you tell me what I am missing. Everything scans as Legal sized paper even though the scanner is set to letter and I believe I have it set to recognize the paper size and to crop the pages.
procedure TfrmDocArchiveScan.actScanExecute(Sender: TObject);
Var
i : Integer;
bmp : TIEBitmap;
begin
if ImageEnMView1.MIO.AcquireParams.SelectedSource.API = ieaNone {ieaTwain} then
begin
If not ImageENMView1.MIO.SetAcquireSource(ieaTwain, Default_Device) then
begin
ShowMessage('Could not acquire scanner.');
Exit;
end;
end;
ImageENMView1.Clear;
SetTwainParams;
if ImageENMView1.MIO.Acquire then
begin
Screen.Cursor := crHourglass;
try
for i := 0 to ImageEnMView1.ImageCount - 1 do
begin
bmp := ImageEnMView1.GetTIEBitmap(i);
ImageEnMView1.Proc.AttachedIEBitmap:=bmp;
ImageEnMView1.Proc.SkewDetection( 0, 10, 0, true );
ImageEnMView1.Proc.RotateAndCrop(0);
ImageEnMView1.Proc.AutoCrop(100, RGB(0,0,0), True); //Black
//ImageEnMView1.Proc.SetTransparentColors(CreateRGB(255, 255, 255), CreateRGB(255, 255, 255), 0);
//ImageEnMView1.Proc.CropTransparentBorder;
ImageEnMView1.ReleaseBitmap(i);
ImageEnMView1.UpdateImage(i);
end;
ImageENMView1.MIO.Params[0].TIFF_Compression := ioTIFF_G4FAX;
ImageENMView1.MIO.Params[0].BitsPerSample := 1;
ImageENMView1.MIO.Params[0].SamplesPerPixel := 1;
ImageENMView1.MIO.DuplicateCompressionInfo(); //Duplicates for additional pages.
if AllowMergeScan then
begin
frmDocArchive.MergeScanToDBDoc;
end
else
begin
SaveDocToDB;
end;
finally
Screen.Cursor := crDefault;
end;
end;
end;
Procedure TfrmDocArchiveScan.SetTwainParams;
begin
Screen.Cursor := crHourGlass;
ImageEnMView1.MIO.TwainParams.PixelType.CurrentValue := Twain_PixelType_BW;
ImageEnMView1.MIO.TwainParams.YResolution.CurrentValue := 200;
ImageEnMView1.MIO.TwainParams.XResolution.CurrentValue := 200;
ImageEnMView1.MIO.TwainParams.BufferedTransfer := True;
ImageEnMView1.MIO.TwainParams.VisibleDialog := cbShowDialog.Checked;
If ImageEnMView1.MIO.TwainParams.IsCapabilitySupported( ICAP_AUTOMATICBORDERDETECTION ) then
begin
ImageENMView1.MIO.TwainParams.AutoBorderDetection := True;
end
else
begin
ShowMessage('Scan auto page size detection is not supported for this scanner');
end;
ImageEnMView1.MIO.TwainParams.UndefinedImageSize := True;
ImageENMView1.MIO.TwainParams.AutoDeskew := True;
ImageENMView1.MIO.TwainParams.AutoRotate := True;
ImageEnMView1.MIO.TwainParams.Update; // verify here...
Screen.Cursor := crDefault;
end;