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
 Rotate Image and its layers at 180 Degree
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

yogiyang

India
725 Posts

Posted - May 15 2020 :  08:43:27  Show Profile  Reply
Hello,

I am using following to rotate image and all its layers at 180 degree
ImageEnView1.LayersRotateAll(180, False, True);

But this is not giving the result that I want.
Here is what I am getting:


But what I want is this:
.

Any ideas as to how can we achieve this?

I have spend a whole day trying to get the math to calculate the location of layers after rotating them 180 degree.

Please help.

TIA


Yogi Yang

yogiyang

India
725 Posts

Posted - May 16 2020 :  01:56:20  Show Profile  Reply
Hello,

It seems I have found a way though not scientifically correct but it works like a charm!!
Here is the code that I am using:

ShowTempHourglass;
ImageEnView1.LockUpdate;
ImageEnView1.LayersCurrent := 0;

//Flip Vertical and then Flip Horizontal
for I := 1 to ImageEnView1.LayersCount - 1 do
begin
  ImageEnView1.Layers[I].PosY := ImageEnView1.Layers[0].Height -
    (ImageEnView1.Layers[I].PosY + ImageEnView1.Layers[I].Height);
  ImageEnView1.Layers[I].Bitmap.flip(fdHorizontal);
  ImageEnView1.Layers[I].PosX := ImageEnView1.Layers[0].Width -
    (ImageEnView1.Layers[I].PosX + ImageEnView1.Layers[I].Width);
  ImageEnView1.Layers[I].Bitmap.flip(fdVertical);
end; 

//Flip Background
ImageEnView1.Layers[0].Bitmap.flip(fdHorizontal);
ImageEnView1.Layers[0].Bitmap.flip(fdVertical);

ImageEnView1.UnlockUpdate;
ImageEnView1.Update;


HTH


Yogi Yang
Go to Top of Page

xequte

38180 Posts

Posted - May 17 2020 :  03:59:58  Show Profile  Reply
Hi Yogi

Yes, when ImageEn rotates a layer it does not reposition it. It would be a nice option in a future version.

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

yogiyang

India
725 Posts

Posted - May 18 2020 :  00:44:14  Show Profile  Reply
Hello Nigel,

This 180 degree rotation works but I am finding it hard to calculate locations of layers when rotated at 90 degree.

I read somewhere on net that we can use Cos and Sin but am not able to find any functions in Delphi that will calculate and return Cos and Sin and again I don't know as to how to implement.

If you have any ideas do share.

TIA


Yogi Yang
Go to Top of Page

xequte

38180 Posts

Posted - May 18 2020 :  18:16:01  Show Profile  Reply
Hi Yogi

Please look in hyieutils.pas. There are whole bunch of useful methods to calculate positions/sizes after rotation.


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