Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-06-15 12:01:41 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-15 12:01:41 +0400
commit9c55e7b9956313bbaf034925e49abbd0260fe457 (patch)
treec63d6d02ce0f9117acb34f1902ba44cf104ae1e4 /source
parent46ea5670db378048fc1339b5e355523842fa82a2 (diff)
add node scale offset for old compositor too - also fix for error in last commit.
Diffstat (limited to 'source')
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.cpp4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_scale.c20
2 files changed, 20 insertions, 4 deletions
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp
index 45e846998af..2e23df73b67 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp
@@ -223,13 +223,13 @@ void ScaleFixedSizeOperation::initExecution()
/* fit X */
const float div = asp_src / asp_dst;
this->relX /= div;
- this->offsetX = ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f;
+ this->offsetX += ((w_src - (w_src * div)) / (w_src / w_dst)) / 2.0f;
}
else {
/* fit Y */
const float div = asp_dst / asp_src;
this->relY /= div;
- this->offsetY = ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f;
+ this->offsetY += ((h_src - (h_src * div)) / (h_src / h_dst)) / 2.0f;
}
this->is_offset = true;
diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.c b/source/blender/nodes/composite/nodes/node_composite_scale.c
index fd4bd643126..1df67724762 100644
--- a/source/blender/nodes/composite/nodes/node_composite_scale.c
+++ b/source/blender/nodes/composite/nodes/node_composite_scale.c
@@ -57,6 +57,7 @@ static void node_composit_exec_scale(void *data, bNode *node, bNodeStack **in, b
CompBuf *stackbuf, *cbuf = typecheck_compbuf(in[0]->data, CB_RGBA);
ImBuf *ibuf;
int newx, newy;
+ float ofsx = 0.0f, ofsy = 0.0f;
if (node->custom1 == CMP_SCALE_RELATIVE) {
newx = MAX2((int)(in[1]->vec[0] * cbuf->x), 1);
@@ -67,6 +68,21 @@ 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) {
+
+ if (node->custom3 != 0.0f || node->custom4 != 0.0f) {
+ const float w_dst = (rd->xsch * rd->size) / 100;
+ const float h_dst = (rd->ysch * rd->size) / 100;
+
+ if (w_dst > h_dst) {
+ ofsx = node->custom3 * w_dst;
+ ofsy = node->custom4 * w_dst;
+ }
+ else {
+ ofsx = node->custom3 * h_dst;
+ ofsy = node->custom4 * h_dst;
+ }
+ }
+
/* supports framing options */
if (node->custom2 & CMP_SCALE_RENDERSIZE_FRAME_ASPECT) {
/* apply aspect from clip */
@@ -133,8 +149,8 @@ static void node_composit_exec_scale(void *data, bNode *node, bNodeStack **in, b
IMB_freeImBuf(ibuf);
/* also do the translation vector */
- stackbuf->xof = (int)(((float)newx / (float)cbuf->x) * (float)cbuf->xof);
- stackbuf->yof = (int)(((float)newy / (float)cbuf->y) * (float)cbuf->yof);
+ stackbuf->xof = (int)(ofsx + (((float)newx / (float)cbuf->x) * (float)cbuf->xof));
+ stackbuf->yof = (int)(ofsy + (((float)newy / (float)cbuf->y) * (float)cbuf->yof));
}
else {
stackbuf = dupalloc_compbuf(cbuf);