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
 Issue when adding Layers

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
PeterPanino Posted - May 07 2023 : 12:01:25
Please look at the attached small demo project where I try to add Layers on the top and the bottom of the image:

attach/PeterPanino/202357115749_AddCaptionsToImage.zip
2.98 KB

Please follow exactly these steps to reproduce the issue:

1. Load an image (e.g., the attached YellowRectangle200x100BlueFrame.png).

2. Click the button "Add TOP Caption" to programmatically add the top caption Layer.

3. Merge the top caption Layer with the Background:



4. Now click "Add BOTTOM Caption" to add the bottom caption Layer programmatically.

You can see that contrary to expectations, there is a gap between the image and the bottom Layer:



Now do the cross-check:

1. Restart the program

2. Load the image

3. But now click the button "Add BOTTOM Caption" first.

You can see that now as expected, the bottom layer is attached correctly at the bottom of the image with no gap:



So how can the gap issue described above be avoided?
5   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - May 09 2023 : 05:34:00
Yes, "visually" it has to move because the view is centered on the background layer, and the background layer is now taller (i.e. its center has changed). This is why centering is best avoided for layer editing:

http://www.imageen.com/help/TImageEnView.Center.html

Also see: loDynamicCanvas

http://www.imageen.com/help/TImageEnView.LayerOptions.html

Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - May 09 2023 : 00:54:36
However, when merging the two objects, you can see that the combined object visually JUMPS to the top. That contradicts the user's expectations, as the image is always displayed at the vertical center of the ImageEnView control (i.e., the top of the image at position 0). Something that places the image outside of the user's view is unproductive (which is done by the action of merging the two objects - not by placing the top Layer above the top edge). From this point of view, my proposed correction helps improve counterproductive behavior.
xequte Posted - May 08 2023 : 17:43:43
Hi Peter

I do not believe it is a bug. If you merge two objects with the top one positioned at y=-50, you would expect the combined object to still be positioned at y=-50, not moved to 0,0.

Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - May 08 2023 : 02:02:32
Hi Nigel,

Thank you for the information about the REAL ISSUE here: The background image changes its vertical position value when merging with a layer outside the background image's boundaries.

This is a bug. As there seems to be no event handler directly associated with merging the background image, I now use this workaround to correct the vertical position of the background image after the merging:

procedure TForm1.ImageEnView1LayerNotify(Sender: TObject; layer: Integer; event: TIELayerEvent);
begin
  if event = ielAction then
    ImageEnView1.Layers[0].PosY := 0;
end;


This workaround fixes the fundamental issue, and now the bottom layer is added at the correct position:



Is there a better way to automatically correct the vertical position of the background image after the merging?
xequte Posted - May 07 2023 : 22:50:29
Hi

You are not taking the position of the background layer into account. If you merge it with "Top Layer" it will be 50 pixels taller and the Y Pos now -50 (inherited from the merge).

If you want to position "Bottom Layer" beneath the background layer, you should use:

  with TIETextLayer(ImageEnView1.CurrentLayer) do
  begin
    PosX := 0;
    PosY := ImageEnView1.Layers[0].PosY + ImageEnView1.Layers[0].Height;
    ...
    Update();
  end;


Nigel
Xequte Software
www.imageen.com