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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-06-14 22:55:35 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-14 22:55:35 +0400
commit91d0ef0a7eaa74df92f1e30299ba0e1720658eb6 (patch)
treee02f148bc019478af26f71a759fd818b3d56604c /source/blender/compositor/operations/COM_ScaleOperation.cpp
parent2cc9ecad553f1154a72efce9f73f9cac80797dfd (diff)
scale node for new compositor now supports framing option.
Diffstat (limited to 'source/blender/compositor/operations/COM_ScaleOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_ScaleOperation.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/source/blender/compositor/operations/COM_ScaleOperation.cpp b/source/blender/compositor/operations/COM_ScaleOperation.cpp
index f0c3b41b61a..aea4da920a0 100644
--- a/source/blender/compositor/operations/COM_ScaleOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScaleOperation.cpp
@@ -190,6 +190,38 @@ void ScaleFixedSizeOperation::initExecution()
this->inputOperation = this->getInputSocketReader(0);
this->relX = inputOperation->getWidth() / (float)this->newWidth;
this->relY = inputOperation->getHeight() / (float)this->newHeight;
+
+ if (this->is_aspect) {
+ /* apply aspect from clip */
+ const float w_src = inputOperation->getWidth();
+ const float h_src = inputOperation->getHeight();
+
+ /* destination aspect is already applied from the camera frame */
+ const float w_dst = this->newWidth;
+ const float h_dst = this->newHeight;
+
+ const float asp_src = w_src / h_src;
+ const float asp_dst = w_dst / h_dst;
+
+ this->offsetX = 0.0f;
+ this->offsetY = 0.0f;
+
+ if (fabsf(asp_src - asp_dst) >= FLT_EPSILON) {
+ if ((asp_src > asp_dst) == (this->is_crop == true)) {
+ /* 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;
+ }
+ 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;
+ }
+ }
+
+ }
}
void ScaleFixedSizeOperation::deinitExecution()
@@ -204,7 +236,14 @@ void ScaleFixedSizeOperation::executePixel(float *color, float x, float y, Pixel
sampler = COM_PS_BICUBIC;
#endif
- this->inputOperation->read(color, x * relX, y * relY, sampler, inputBuffers);
+ if (this->is_aspect) {
+ float nx = ((x - this->offsetX) * relX);
+ float ny = ((y - this->offsetY) * relY);
+ this->inputOperation->read(color, nx, ny, sampler, inputBuffers);
+ }
+ else {
+ this->inputOperation->read(color, x * relX, y * relY, sampler, inputBuffers);
+ }
}
bool ScaleFixedSizeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)