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
 How to use TImageEnMView.RotateAndCrop in MultiSelect mode

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
Stalker4 Posted - Feb 13 2025 : 05:18:28
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.
7   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Feb 17 2025 : 16:46:40


Nigel
Xequte Software
www.imageen.com
Stalker4 Posted - Feb 17 2025 : 04:30:46
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 }
xequte Posted - Feb 17 2025 : 02:51:46
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
Stalker4 Posted - Feb 17 2025 : 02:43:14
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.
xequte Posted - Feb 15 2025 : 18:13:54
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
Stalker4 Posted - Feb 14 2025 : 02:40:51
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
xequte Posted - Feb 13 2025 : 14:57:11
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