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 calculate Ratio properly?

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
yogiyang Posted - Jan 31 2015 : 07:37:13
My problem is a bit complicate so let me try and explain it here...

I have implemented a log in which if a user Resizes currently active Layer interactively using Mouse on completion of Resizing process I check if the Layer above current layer is Mask of not and if it is Mask I also resize that layer as per the current location and size. I have programmed this part in OnLayerNofiy event.

But my problem starts here:
If the Mask Layer above current Layer is smaller than current layer (and it X, Y location are different also) then it gets sized to the size of current layer.

Instead of this what I want to achieve is that if the Layer is moved of Resized then the Mask Layer should also get moved or resized appropriately taking into consideration the current location as well as size of Mask Layer compared to Current Layer.

How to achieve this?

Please help.

TIA




Yogi Yang
3   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Feb 04 2015 : 19:23:44
Hi Yogi

You will need to ensure that you maintain the original aspect ratio of your mask.

See the GetImageRectWithinArea methods in hyieutils.pas, which should get you going.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
yogiyang Posted - Feb 04 2015 : 07:34:23
Hi Nigel,
quote:
In what way does it not work?

It works properly but my problem is a bit more deep than what is looks on the surface.

I have a Layer which had following geometry:
X is 10 px
Y is 7 px
Width is 346 px
Height is 600 px

I have a Mask Layer which has following geometry:
X is 23 px
Y is 10 px
Width is 250 px
Height is 489 px

Now when I code in OnLayerNotify event as follows:

if (event = ielResized) then
begin
LL := ImageEnView1.Layers[ImageEnView1.LayersCurrent].PosX;
LT := ImageEnView1.Layers[ImageEnView1.LayersCurrent].PosY;
LW := ImageEnView1.Layers[ImageEnView1.LayersCurrent].Width;
LH := ImageEnView1.Layers[ImageEnView1.LayersCurrent].Height;

if (ImageEnView1.LayersCurrent) < (ImageEnView1.LayersCount - 1) then
begin
	if ImageEnView1.Layers[ImageEnView1.LayersCurrent + 1].IsMask = True then
	begin
	  ImageEnView1.LockUpdate;
	  ImageEnView1.Proc.SaveUndo();
	  ImageEnView1.Layers[ImageEnView1.LayersCurrent + 1].PosX := LL;
	  ImageEnView1.Layers[ImageEnView1.LayersCurrent + 1].PosY := LT;
	  ImageEnView1.Layers[ImageEnView1.LayersCurrent + 1].Width := LW;
	  ImageEnView1.Layers[ImageEnView1.LayersCurrent + 1].Height := LH;
	  ImageEnView1.UnLockUpdate;
	end;
end;


The Mask Layer's X, Y, Width and Height get set to Active Layers X, Y, Width and Height.

So how can I solve this?

One way would be to calculate some kind of ratio but I don't know as to how to do this.

TIA

Yogi Yang




Yogi Yang
xequte Posted - Feb 02 2015 : 15:07:45
Hi Yogi

It sounds like you are doing it the right way. In OnLayerNotify you would check for a resize and automatically set the size and position of the associated mask.

In what way does it not work?


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com