diff options
Diffstat (limited to 'source/blender/compositor/operations/COM_KeyingBlurOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_KeyingBlurOperation.cpp | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp index 9c7a33c1327..3285bd32039 100644 --- a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp @@ -33,7 +33,8 @@ KeyingBlurOperation::KeyingBlurOperation() : NodeOperation() this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->size = 0.0f; + this->m_size = 0; + this->m_axis = BLUR_AXIS_X; this->setComplex(true); } @@ -53,16 +54,28 @@ void KeyingBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer int bufferWidth = inputBuffer->getWidth(); int bufferHeight = inputBuffer->getHeight(); - int i, j, count = 0; + int i, count = 0; float average = 0.0f; - for (i = -this->size + 1; i < this->size; i++) { - for (j = -this->size + 1; j < this->size; j++) { - int cx = x + j, cy = y + i; + if (this->m_axis == 0) { + for (i = -this->m_size + 1; i < this->m_size; i++) { + int cx = x + i; - if (cx >= 0 && cx < bufferWidth && cy >= 0 && cy < bufferHeight) { - int bufferIndex = (cy * bufferWidth + cx) * 4; + if (cx >= 0 && cx < bufferWidth) { + int bufferIndex = (y * bufferWidth + cx) * 4; + + average += buffer[bufferIndex]; + count++; + } + } + } + else { + for (i = -this->m_size + 1; i < this->m_size; i++) { + int cy = y + i; + + if (cy >= 0 && cy < bufferHeight) { + int bufferIndex = (cy * bufferWidth + x) * 4; average += buffer[bufferIndex]; count++; @@ -79,10 +92,18 @@ bool KeyingBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuff { rcti newInput; - newInput.xmin = 0; - newInput.ymin = 0; - newInput.xmax = this->getWidth(); - newInput.ymax = this->getHeight(); + if (this->m_axis == BLUR_AXIS_X) { + newInput.xmin = input->xmin - this->m_size; + newInput.ymin = input->ymin; + newInput.xmax = input->xmax + this->m_size; + newInput.ymax = input->ymax; + } + else { + newInput.xmin = input->xmin; + newInput.ymin = input->ymin - this->m_size; + newInput.xmax = input->xmax; + newInput.ymax = input->ymax + this->m_size; + } return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } |