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
 Layers fixing
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

spetric

Croatia
308 Posts

Posted - Jun 12 2020 :  14:22:17  Show Profile  Reply
Hi,

Is there a way to check if layer was rotated/resized?

Currently, in order to avoid unnecessary overhead, I'm using userdata to set and check if there was any rotation/resizing:


if (!userData) // oops, we do not have userData (throw an error in next version)
   continue;
if (*userData == 0) // no rotation, no resizing
   continue;
_primaryImageContainer->PaintView->Layers[i]->UseResampleFilter = true;
if (*userData & px_MASK_LRESIZED )
   _primaryImageContainer->PaintView->LayersFixSizes(i);
else if (*userData & px_MASK_LROTATED)
   _primaryImageContainer->PaintView->LayersFixRotations(i);
_primaryImageContainer->PaintView->Layers[i]->UseResampleFilter = false;
*userData = 0;
// and finally, recreate image zoo
_paintForm->LayerFixed(i);


The last instruction recreates "image zoo" (sharing bitmap with drawing engine, IPP and OpenCV).

I would like to get rid of userdata checking and recreate "image zoo" only if layer was rotated or resized. So is there more elegant way to know "geometry situation"?

I'm using version 8.1.1.

TIA,
Siniša

xequte

38614 Posts

Posted - Jun 14 2020 :  17:32:37  Show Profile  Reply
Hi Sinisa

If an image layer has been resized, then lyr.Width <> lyr.Bitmap.Width. If it has been rotated then lyr.Rotate <> 0. Alternatively, you can check for ielRotated or ielResized in the OnLayerNotifyEx event.

https://www.imageen.com/help/TImageEnView.OnLayerNotifyEx.html

Is that what you are looking for?

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

spetric

Croatia
308 Posts

Posted - Jun 16 2020 :  14:41:28  Show Profile  Reply
Hi Nigel,

Yes, (lyr.Width <> lyr.Bitmap.Width) or (lyr.Height <> lyr.Bitmap.Height) or (lyr.Rotate <> 0) seems like good solution.

Currently I'm using OnLayerNotify to set UserData (checking ielResized or ielRotated).

One question: when I rotate a layer and get back to rotate angle 0, does layer fixation change (recreate) Bitmap or ImageEn internally knows that there was no rotation and does not recreate bitmnap?

Siniša
Go to Top of Page

xequte

38614 Posts

Posted - Jun 17 2020 :  02:17:40  Show Profile  Reply
Hi Siniša

Rotate is a visual property only. Setting it does not affect the bitmap at all, until LayersFixRotations is called.

https://www.imageen.com/help/TImageEnView.LayersFixRotations.html

After LayersFixRotations the image is modified and Rotate is reset to 0.



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

spetric

Croatia
308 Posts

Posted - Jun 17 2020 :  13:45:35  Show Profile  Reply
Hi Nigel,

Yes, I know that rotation does not change bitmap until fixing rotation is called, my question was wrongly constructed. I'll simplify it:

When rotate angle is zero and LayersFixRotations is called, does the bitmap change?

Siniša
Go to Top of Page

xequte

38614 Posts

Posted - Jun 17 2020 :  16:27:23  Show Profile  Reply
Hi Siniša

No, the layer is not changed if rotate = 0 (specifically, the layer is skipped in the LayersFixRotations method if rotate = 0).

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

spetric

Croatia
308 Posts

Posted - Jun 18 2020 :  14:47:48  Show Profile  Reply
Hi Nigel,

Thanks a lot. I really don't know why I'm bothering with UserData
to set and check if there was rotation/resize. Now I can simplify
the code.

Siniša



Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: