diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-06-14 20:55:55 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-06-14 20:55:55 +0400 |
commit | ffc9e340b12ffbebbf193f573a3bbe072b9f5df6 (patch) | |
tree | 447a70a6e04bddb073dede542912e94b99bc50ab /source/blender/nodes/composite | |
parent | 550824968ce4ecea3718e5744b48812be6c5d554 (diff) |
new scaling options to scale footage without stretching - add stretch/fit/crop to compositor scale node, default behavior isnt changed.
this is only added for the old compositor, will add to the new compositor next.
Diffstat (limited to 'source/blender/nodes/composite')
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_scale.c | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.c b/source/blender/nodes/composite/nodes/node_composite_scale.c index 69d76ed03e0..fd4bd643126 100644 --- a/source/blender/nodes/composite/nodes/node_composite_scale.c +++ b/source/blender/nodes/composite/nodes/node_composite_scale.c @@ -67,8 +67,44 @@ static void node_composit_exec_scale(void *data, bNode *node, bNodeStack **in, b newy = cbuf->y * (rd->size / 100.0f); } else if (node->custom1 == CMP_SCALE_RENDERPERCENT) { - newx = (rd->xsch * rd->size) / 100; - newy = (rd->ysch * rd->size) / 100; + /* supports framing options */ + if (node->custom2 & CMP_SCALE_RENDERSIZE_FRAME_ASPECT) { + /* apply aspect from clip */ + const float w_src = cbuf->x; + const float h_src = cbuf->y; + + /* destination aspect is already applied from the camera frame */ + const float w_dst = (rd->xsch * rd->size) / 100; + const float h_dst = (rd->ysch * rd->size) / 100; + + const float asp_src = w_src / h_src; + const float asp_dst = w_dst / h_dst; + + if (fabsf(asp_src - asp_dst) >= FLT_EPSILON) { + if ((asp_src > asp_dst) == ((node->custom2 & CMP_SCALE_RENDERSIZE_FRAME_CROP) != 0)) { + /* fit X */ + const float div = asp_src / asp_dst; + newx = w_dst * div; + newy = h_dst; + } + else { + /* fit Y */ + const float div = asp_dst / asp_src; + newx = w_dst; + newy = h_dst * div; + } + } + else { + /* same as below - no aspect correction needed */ + newx = w_dst; + newy = h_dst; + } + } + else { + /* stretch */ + newx = (rd->xsch * rd->size) / 100; + newy = (rd->ysch * rd->size) / 100; + } } else { /* CMP_SCALE_ABSOLUTE */ newx = MAX2((int)in[1]->vec[0], 1); |