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
 How to use TImageEnMView.RotateAndCrop in MultiSelect mode
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Stalker4

Ukraine
39 Posts

Posted - Feb 13 2025 :  05:18:28  Show Profile  Reply
Hi,

ImageEn 13.0, Delphi 12.1 Update 1

I add a button "Test" with this code to your AllAcquire demo:
procedure TfrmMain.TestButtonClick(Sender: TObject);
var
  nSelIdx :Integer;
  nAngle  :Double;

begin

 ImageEnMView1.LockUpdate();
 try

   for var nCou := 0 to ImageEnMView1.MultiSelectedImagesCount-1 do begin

     nSelIdx := ImageEnMView1.MultiSelectedImages[nCou];
     ImageEnMView1.SelectedImage := nSelIdx;
     nAngle := ImageEnMView1.Proc.SkewDetection();
     ImageEnMView1.Proc.RotateAndCrop(nAngle, ierBilinear, 
                                      ImageEnMView1.IEBitmap.Height / ImageEnMView1.IEBitmap.Width, 
                                      iecaSkewedDocument);

   end;

 finally
   ImageEnMView1.UnlockUpdate();
 end; 

end;

Setting properties:
MultiSelectionOptions := [iemoSelectOnMouseUp];
EnableMultiSelect := True;

I start the demo, scan a few pages. It is desirable to scan pages in a slightly crooked form.
Select several scanned pages and press the "Test" button.
If the program is built in 32-bit, all selected pages except the first one are not aligned.
If the program is built in 64-bit, an error occurs when aligning the second page (calling RotateAndCrop):
Project AllAcquire.exe raised exception class EAccessViolation with 
message 'Access violation at address 000000000103E573. Read of address 0000000000000000'.

This is the call stack:
:000000000103E573 RC + $53
:000000000103E60A Bilinear + $8A
:000000000103F393 IEQRotateTo24 + $3B3
:000000000103E40F IEQRotateTo + $EF
:000000000103E2CC IEQRotate + $9C
:000000000118147F TIEBitmap.RotateEx + $1FF
:000000000101BA55 TImageEnProc.Rotate + $245
:000000000105AE20 TImageEnProc.RotateAndCrop + $170

EurekaLog gives this error:
Application made attempt to call method of already 
deleted object: $000001AAC5254370 OBJECT [TIEBitmap] 456 bytes.

xequte

38793 Posts

Posted - Feb 13 2025 :  14:57:11  Show Profile  Reply
Hi

Please attach/forward a selection of your skewed documents so we can reproduce the issue here.

Also, if possible, please use the latest version, v13.7.0.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Stalker4

Ukraine
39 Posts

Posted - Feb 14 2025 :  02:40:51  Show Profile  Reply
Crooked image in atach.
ImageEn 13.7 Trial I ordered on your site, as soon as the link to it comes I will download and check it.
But the problem can be seen and on a simpler options can be in my example lines with SkewDetection and RotateAndCrop replace with a line with Rotate.
ImageEnMView1.Proc.Rotate(90, ierBilinear);
In this case, although the AV error does not occur, but only the first of the selected pages is rotated. So the problem still remains.

attach/Stalker4/202521431420_pict.zip
242.36 KB
Go to Top of Page

xequte

38793 Posts

Posted - Feb 15 2025 :  18:13:54  Show Profile  Reply
Setting SelectedImage will clear the existing multiple selection, so either:

- Get a list of all selected images first before iterating through them (use this list rather than calling TImageEnMView.MultiSelectedImages)

https://www.imageen.com/help/TImageEnMView.MultiSelectedImagesList.html


- Use GetTIEBitmap rather than using Proc

https://www.imageen.com/help/TImageEnMView.GetTIEBitmap.html


- Get the latest beta which supports SelectedImage

// Deskew all selected scanned documents
ImageEnMView1.LockUpdate();
try
  for i := 0 to ImageEnMView1.MultiSelectedImagesCount - 1 do
  begin
    selIdx := ImageEnMView1.MultiSelectedImages[i];
    ImageEnMView1.SelectImage( selIdx );
    angle := ImageEnMView1.Proc.SkewDetection();
    ImageEnMView1.Proc.RotateAndCrop( angle, ierBilinear, 
                                      ImageEnMView1.IEBitmap.Height / ImageEnMView1.IEBitmap.Width, 
                                      iecaSkewedDocument );
  end;
finally
  ImageEnMView1.UnlockUpdate();
end;


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Stalker4

Ukraine
39 Posts

Posted - Feb 17 2025 :  02:43:14  Show Profile  Reply
Unfortunately, using "GetTIEBitmap" instead of "Proc" will not work, because SkewDetection and RotateAndCrop methods are available only in TImageEnProc class. The TIEBitmap class does not have these methods.
Go to Top of Page

xequte

38793 Posts

Posted - Feb 17 2025 :  02:51:46  Show Profile  Reply
You can attach a TIEBitmap to a TImageEnProc:

http://www.imageen.com/help/TImageEnProc.CreateFromBitmap.html

Or in newer versions you can just use the helper property TIEBitmap.Proc:

http://www.imageen.com/help/TIEBitmapHelper.Proc.html


Nigel
Xequte Software
www.imageen.com
Go to Top of Page

Stalker4

Ukraine
39 Posts

Posted - Feb 17 2025 :  04:30:46  Show Profile  Reply
Hi,

Through TImageEnProc everything works without errors. Thanks for the hint.


ListImageEnMView.LockUpdate();
try

  for var nCou := 0 to ListImageEnMView.MultiSelectedImagesCount-1 do begin

    nSelIdx := ListImageEnMView.MultiSelectedImages[nCou];
    oBmp := ListImageEnMView.GetTIEBitmap(nSelIdx);
    try

      oProc := TImageEnProc.CreateFromBitmap(oBmp);
      try
        nAngle := oProc.SkewDetection();
        oProc.RotateAndCrop(nAngle, ierBilinear, oBmp.Height / oBmp.Width, iecaSkewedDocument);
      finally
        FreeAndNil(oProc);
      end; { try }

    finally
      ListImageEnMView.ReleaseBitmap(nSelIdx, True);
    end; { try }

  end; { for }

finally
  ListImageEnMView.UnlockUpdate();
end; { try }
Go to Top of Page

xequte

38793 Posts

Posted - Feb 17 2025 :  16:46:40  Show Profile  Reply


Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: