Skip to main content
Nathan Lovell_52
Inspiring
November 22, 2020
Answered

SmartFX Expand Layer Bounds - Shifter Example Project

  • November 22, 2020
  • 3 replies
  • 1181 views

Using SmartFX and expanding on the 'Shifter' Example project, how can I expand the bounds of my square layer here to show the shifted image on top in its entirely, rather than being restricted to the original square?  

I know it is something to do with the extra and/or PF_CheckoutResult but cannot pinpoint how by messing with the result_rects!

 

Thanks!

This topic has been closed for replies.
Correct answer James Whiffin

In my case, I expanded the result_rect, then unioned it with the output rects which also expanded them:

 

PF_Rect expandedRect = in_result.result_rect;

expandedRect.left -= stuffP->innerExpansion.left; // expand by subtracting on the left and top
expandedRect.top -= stuffP->innerExpansion.top;
expandedRect.right += stuffP->innerExpansion.right;
expandedRect.bottom += stuffP->innerExpansion.bottom;

UnionLRect(&expandedRect, &in_result.result_rect);
UnionLRect(&expandedRect, &in_result.max_result_rect);

 

UnionLRect(&in_result.result_rect, &extra->output->result_rect);

UnionLRect(&in_result.max_result_rect, &extra->output->max_result_rect);

 

I don't quite understand why your code gave a magic error though.

3 replies

James Whiffin
Legend
November 26, 2020

To expand the buffer in smartFX, in pre render you need to expand the result_rect and max_result_rect and then set the flag 

extra->output->flags = PF_RenderOutputFlag_RETURNS_EXTRA_PIXELS;

Nathan Lovell_52
Inspiring
November 28, 2020

@James Whiffin Which rects are we talking about, the extra or the input? I have tried on the extra and the input in various places in the PreRender(), but I get 'AEGP Magic Error'. Is this the right format? 

James Whiffin
James WhiffinCorrect answer
Legend
November 29, 2020

In my case, I expanded the result_rect, then unioned it with the output rects which also expanded them:

 

PF_Rect expandedRect = in_result.result_rect;

expandedRect.left -= stuffP->innerExpansion.left; // expand by subtracting on the left and top
expandedRect.top -= stuffP->innerExpansion.top;
expandedRect.right += stuffP->innerExpansion.right;
expandedRect.bottom += stuffP->innerExpansion.bottom;

UnionLRect(&expandedRect, &in_result.result_rect);
UnionLRect(&expandedRect, &in_result.max_result_rect);

 

UnionLRect(&in_result.result_rect, &extra->output->result_rect);

UnionLRect(&in_result.max_result_rect, &extra->output->max_result_rect);

 

I don't quite understand why your code gave a magic error though.

Bruce Bullis
Community Manager
Community Manager
November 25, 2020

If you want to go outside the bounds of the original layer to which the effect is applied, you'll need to resize the output buffer; see the (aptly-named) Resizer sample.

Community Expert
November 22, 2020

Try applying Grow Bounds before you apply Shifter.

Nathan Lovell_52
Inspiring
November 22, 2020

Rick, I don't believe there are any example projects or code for that! I'm asking how to do it via the SDK, not applying premade effects.