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
 Is the Undo mechanism (ObjUndo) and drawing on ImageEnVect.IEBitmap compatible ?

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 14 2025 : 05:39:37
Hi,

ImageEn 13.0, Delphi 12.1 (Update 1)

There is a demo of this problem in atach.
There is some scanned document. I need to color in some parts of it. But I also want to be able to roll back some of the last changes (coloring) in it. For this I wanted to use the "Proc.Undo" (or "ObjUndo") rollback mechanism.

But it doesn't work for some reason, it doesn't want to roll back changes.

In the demo I try to use the automatic mode of rollback changes (AutoUndo = True), but I tried to use the manual mechanism as well. (AutoUndo = False), but it also almost does not work - after (ObjAutoUndo = False and ObjSaveUndo, changes are not removed at all, and after (Proc.AutoUndo = False and Proc.SaveUndo) only one last change is removed.
Question: Is this an ImageEn error or am I doing something wrong ?

attach/Stalker4/202521453928_undo.zip
318.29 KB
4   L A T E S T    R E P L I E S    (Newest First)
Stalker4 Posted - Feb 18 2025 : 03:36:40
Hi,

If You watch my demo (undo2) from my previous post, you will see that I did everything there as you wrote in your last post.
And yet, for some reason only one, the most recent change is canceled.

Can You make some adjustments to my demo (Undo2), so that it would undo all changes from the last to the first one in sequence ?
xequte Posted - Feb 17 2025 : 16:51:59
1. Instead you should be using ImageEnView1.Proc.Undo();

https://www.imageen.com/help/TImageEnProc.Undo.html

2. Before each change call SaveUndo() to save that state to the undo stack. Then each time you call ImageEnView1.Proc.Undo() you will move backwards one step in the undo stack

3. AutoUndo does not support any canvas or bitmap methods (only TImageEnProc ones). You need to manually call ImageEnView1.Proc.SaveUndo();

Also ensure you set a reasonable undo limit:

ImageEnView1.Proc.UndoLimit := 50;

https://www.imageen.com/help/TImageEnProc.UndoLimit.html

Nigel
Xequte Software
www.imageen.com
Stalker4 Posted - Feb 17 2025 : 03:34:42
Hi,

There's a new demo in atach.

1. replaced TImageEnVect with TImageEnView (although ImageEnView has no ObjUndo methods and properties).

2. I changed the rest of the code according to your example, but still if I make several selections, the changes are canceled only for the last selection. But each time Proc.Undo should undo one last selection in sequence.

3. As for the use of Canvas, there is a commented line in the code using IEBitmap.Rectangle call (i.e. without canvas) - Proc.AutoUndo doesn't work with it either.

Maybe coloring of text (in my example I do it using Rectangle method) is not compatible with Proc.AutoUndo ?

attach/Stalker4/202521733533_undo2.zip
318.2 KB
xequte Posted - Feb 15 2025 : 16:22:57
Hi

Firstly, avoid using TImageEnVect, it is a legacy component (and you make no use of the vect functionality in your demo).

Your code draws directly to the canvas. Direct editing of the bitmap does not trigger automatic saving of an undo, so you will need to manually save the undo first:

// Allow undo of an operation upon the bitmap canvas
ImageEnView1.Proc.SaveUndo( 'Draw Rectangle', ieuImage );
ImageEnView1.IEBitmap.Canvas.Pen.Color := clRed;
ImageEnView1.IEBitmap.Canvas.Rectangle( X1, Y1, X2, Y2 );
ImageEnView1.Update();

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

Nigel
Xequte Software
www.imageen.com