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
 insert image into large tif file straight from scanner

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
AndNit Posted - Jan 02 2023 : 07:56:11
Good Morning...

I would like to know how can I include images within the large tif file through the scanner?

I used your demo for other features and it worked fine, but I couldn't update the tiff and save straight from the scanner.



I used this example for the other functions:

https://www.imageen.com/files/demos/run/InputOutput/TiffHandler2/TiffHandler2.zip
16   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jan 17 2023 : 19:40:43
Nice one

Nigel
Xequte Software
www.imageen.com
AndNit Posted - Jan 12 2023 : 15:21:08
Thank you very much, it worked perfectly. In case anyone needs it, the solution looks like this:


Button that calls the scanner

procedure TfrmConsCert.bbDigitalizaClick(Sender: TObject);
var
   insertPos: integer;
   ip  : integer;
   srip : TSearchRec;
begin
  try
    MIOTemp.MIO.AcquireParams.SetSource(ieaTwain, cbSelecionaScan.Items[cbSelecionaScan.ItemIndex]);
    MIOTemp.MIO.Acquire();
  finally
  end;
  LoadCurrentTIFFPage();
  Tiff.WriteFile(CaminhoImgDoc);
  LoadTiffFile(CaminhoImgDoc);
  GravaHashSHA2(CaminhoImgDoc);
  ip  := FindFirst(ExtractFilePath(Application.ExeName) + 'IncluiPagina\*.*', faAnyFile, srip);
  while ip = 0 do begin
    DeleteFile(ExtractFilePath(Application.ExeName) + 'IncluiPagina\' + srip.Name);
    ip := FindNext(srip);
  end;

event ImageEnMView1AcquireBitmap 

procedure TfrmConsCert.MIOTempAcquireBitmap(Sender: TObject; ABitmap: TIEBitmap;
  DpiX, DpiY: Integer; var Handled: Boolean);
var
  filename: string;
begin
  filename := (ExtractFilePath(Application.ExeName) + 'IncluiPagina\' +  'Scan_' + FormatDateTime( 'yymmdd-hhnnss-zzz', Now ) + '.jpg');
  ABitmap.Write( filename);
  Tiff.InsertPageAsFile( filename, Tiff.GetPagesCount );
  Handled := True;
end;
xequte Posted - Jan 12 2023 : 14:13:26
Hi

You cannot use a TImageEnIO if you want multiple pages. You need to use a TImageEnMIO and handle each image that is returned in the ImageEnMView1AcquireBitmap event (as described above). It will be easier if you add the TImageEnMIO to your form rather than creating a temporary one.

Nigel
Xequte Software
www.imageen.com
AndNit Posted - Jan 12 2023 : 10:03:39
procedure TfrmConsCert.bbDigitalizaClick(Sender: TObject);
var
  io: TImageEnIO;
  insertPos: integer;
begin
  io := TImageEnIO.Create( nil );
  try
    io.AcquireParams.SetSource(ieaTwain, cbSelecionaScan.Items[cbSelecionaScan.ItemIndex]);
    if io.Acquire() then
    begin
      insertPos := Tiff.GetPagesCount; // Append to end

      // Insert it into our TIFF
      Tiff.InsertPageAsImage( io, insertPos );
    end;
  finally
    io.Free;
  end;
  LoadCurrentTIFFPage();
  Tiff.WriteFile(File path);
end;



The way you indicated it works, but scanning one page at a time. My need is:

1: Inserting pages into an existing tif file with Multipage Scan via ADF Scanner

2 - Update the Tif file using TIETIFFHandler

3 - Save the Tif in the directory

4 - Update the thumbnails in the
TImageEnMView

I really need this solution, I count on your help.

Thanks
AndNit Posted - Jan 12 2023 : 09:49:47
Hi,
I'm still having trouble scanning multiple pages and updating the Tif file. I didn't quite understand the last code you sent me and I couldn't move forward with the solution. Could you help me with this problem?
xequte Posted - Jan 05 2023 : 21:12:42

procedure TForm1.ImageEnMView1AcquireBitmap(Sender: TObject; ABitmap: TIEBitmap; DpiX, DpiY: Integer; var Handled: Boolean);
var
  filename: string;
begin
  filename := GetTempFolder() + 'Scan_' + FormatDateTime( 'yymmdd-hhnnss-zzz', Now ) + '.jpg';
  ABitmap.Write( filename);      
  Tiff.InsertPageAsFile( filename, Tiff.GetPagesCount );
  Handled := True;
end;

OR

procedure TForm1.ImageEnMView1AcquireBitmap(Sender: TObject; ABitmap: TIEBitmap; DpiX, DpiY: Integer; var Handled: Boolean);
begin
  Tiff.InsertPageAsImage( ABitmap, Tiff.GetPagesCount );
  Handled := True;
end;


Nigel
Xequte Software
www.imageen.com
AndNit Posted - Jan 05 2023 : 18:31:59
Would you have an example of this last solution presented? thank you very much
xequte Posted - Jan 05 2023 : 18:24:46
If you don't wish to use the new beta, then save the acquired bitmap to a temp file and add it using InsertPageAsFile()

Nigel
Xequte Software
www.imageen.com
xequte Posted - Jan 05 2023 : 18:24:04
Hi

Please email me for the current beta. It allows you to add TIEBitmaps using InsertPageAsImage().

Then you can add an TImageEnMIO object to your form, and call ImageEnMIO.Acquire() to retrieve multiple scans.

In the OnAcquireBitmap bitmap event, add the scanned bitmap to the TIFF as above...

http://www.imageen.com/help/TImageEnMIO.OnAcquireBitmap.html

Nigel
Xequte Software
www.imageen.com
AndNit Posted - Jan 05 2023 : 17:46:06
I tried to change the variable

io: TImageEnIO;

per

mio: TImageEnMIO;

but it still doesn't work
AndNit Posted - Jan 05 2023 : 17:36:05
Primeor Thanks for the solution, but I apologize for the insistence. We are progressing well in the process, but this way, only the first page scanned is assigned to the tif file, the other pages are disregarded, how to include all pages scanned through the scanner to the tif file?
xequte Posted - Jan 05 2023 : 16:29:28
Sorry, the code I posted is from the current beta. In your version, please use:

procedure TfrmConsCert.bbDigitalizaClick(Sender: TObject);
var
  io: TImageEnIO;
  insertPos: integer;
begin
  io := TImageEnIO.Create( nil );
  try
    io.AcquireParams.SetSource(ieaTwain, cbSelecionaScan.Items[cbSelecionaScan.ItemIndex]);
    if io.Acquire() then
    begin
      insertPos := Tiff.GetPagesCount; // Append to end

      // Insert it into our TIFF
      Tiff.InsertPageAsImage( io, insertPos );
    end;
  finally
    io.Free;
  end;
  LoadCurrentTIFFPage();
  Tiff.WriteFile(File path);
end;


Nigel
Xequte Software
www.imageen.com
AndNit Posted - Jan 05 2023 : 08:21:00
Hi,

I tried to implement the code you indicated, but the tif file does not undergo any changes, neither in the file in the folder nor in the TImageEnMView component

I can scan the images normally through the scanner, but they don't go anywhere apparently lol.

Would you help me? The code I'm using is this.



procedure TfrmConsCert.bbDigitalizaClick(Sender: TObject);
var
  io: TImageEnIO;
  insertPos: integer;
begin
  io := TImageEnIO.Create( nil );
  try
    io.AcquireParams.SetSource(ieaTwain, cbSelecionaScan.Items[cbSelecionaScan.ItemIndex]);
    if io.Acquire() then
    begin
      insertPos := Tiff.GetPagesCount; // Append to end

      // Insert it into our TIFF
      Tiff.InsertPageAsImage( io.IEBitmap, insertPos );
    end;
  finally
    io.Free;
  end;
  LoadCurrentTIFFPage();
  Tiff.WriteFile(File path);
end;

xequte Posted - Jan 04 2023 : 19:26:02
Hi

If you want to stick with the TIETIFFHandler you can insert images from the scanner as follows...

// Add a page from the scanner
procedure TMainForm.btnAddFromScannerClick(Sender: TObject);
var
  io: TImageEnIO;
  insertPos: integer;
begin
  io := TImageEnIO.Create( nil );
  try
    if io.Acquire() then
    begin
      insertPos := Tiff.GetPagesCount; // Append to end

      // Insert it into our TIFF
      Tiff.InsertPageAsImage( io.IEBitmap, insertPos );
  finally
    io.Free;
  end;
end;


Nigel
Xequte Software
www.imageen.com
AndNit Posted - Jan 04 2023 : 18:13:02
Hi Nigel,

I already do it the way you told me, but when I save the TImageEnMView it takes a LONG time, it's worth remembering that I'm working with 500 MB / 1GB files.

Your example for a large tif, loads an image from the directory and saves it very quickly, it's perfect, I would like to be able to do that, but capturing it from the scanner.

Using TImageEnMView, after capturing a new image directly from the scanner, I use this line to save the file, and it takes a long time, how can I resolve this issue?

One of the things I thought of was scanning to a temporary folder and then uploading the files to the tif with these codes.

Tiff.InsertPageAsFile( temporary image, insertPos );

LoadCurrentTIFFPage();

Tiff.WriteFile( SaveImageEnDialog1.FileName );

would there be anything simpler?

This is the code I use to save the TImageEnMView after adding a new image from the scanner, but, as mentioned before, it takes too long.

ImageEnMView1.MIO.SaveToFile(ImgDocPath)

Thank you for your attention.

Thanks.
xequte Posted - Jan 03 2023 : 19:55:49
Hi

You are better to use a TImageEnMView, which stores a set of images that can be saved to a multi-page TIFF file. You can add to the TImageEnMView image list by scanning or loading images from file.

Take a look at the ImageAcquisition\AllAcquire\AllAcquire.dpr demo, and let us know if you need more advice.


Nigel
Xequte Software
www.imageen.com