diff options
author | Manuel Castilla <manzanilla> | 2022-01-04 10:22:07 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2022-01-04 10:22:37 +0300 |
commit | a2a02e39941735a4a5744c133302486cb005b8a0 (patch) | |
tree | 6fdc9f66c110f2ef41263cce1a991656ffe56618 /source | |
parent | 325beef7af93531e52cb512485ef7baec49e235c (diff) |
Fix T90830: Crop node cropping is one pixel short
Currently the crop higher limits are inclusive too which contradicts
the documentation as it says that if Left and Right are both 50, it
will result in a zero-sized image. And the result is one pixel out of
the crop gizmo, which is another hint that this is not intended.
In "Full Frame" experimental mode it's two pixels short because of
a misuse of `BLI_rcti_isect_pt` as it considers max limits inclusive.
Reviewed By: jbakker
Maniphest Tasks: T90830
Differential Revision: https://developer.blender.org/D12786
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/compositor/operations/COM_CropOperation.cc | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/source/blender/compositor/operations/COM_CropOperation.cc b/source/blender/compositor/operations/COM_CropOperation.cc index 5d78ed9d41a..2385a0b54ba 100644 --- a/source/blender/compositor/operations/COM_CropOperation.cc +++ b/source/blender/compositor/operations/COM_CropOperation.cc @@ -42,22 +42,22 @@ void CropBaseOperation::update_area() local_settings.y1 = height * local_settings.fac_y1; local_settings.y2 = height * local_settings.fac_y2; } - if (width <= local_settings.x1 + 1) { - local_settings.x1 = width - 1; + if (width < local_settings.x1) { + local_settings.x1 = width; } - if (height <= local_settings.y1 + 1) { - local_settings.y1 = height - 1; + if (height < local_settings.y1) { + local_settings.y1 = height; } - if (width <= local_settings.x2 + 1) { - local_settings.x2 = width - 1; + if (width < local_settings.x2) { + local_settings.x2 = width; } - if (height <= local_settings.y2 + 1) { - local_settings.y2 = height - 1; + if (height < local_settings.y2) { + local_settings.y2 = height; } - xmax_ = MAX2(local_settings.x1, local_settings.x2) + 1; + xmax_ = MAX2(local_settings.x1, local_settings.x2); xmin_ = MIN2(local_settings.x1, local_settings.x2); - ymax_ = MAX2(local_settings.y1, local_settings.y2) + 1; + ymax_ = MAX2(local_settings.y1, local_settings.y2); ymin_ = MIN2(local_settings.y1, local_settings.y2); } else { @@ -98,10 +98,8 @@ void CropOperation::update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span<MemoryBuffer *> inputs) { - rcti crop_area; - BLI_rcti_init(&crop_area, xmin_, xmax_, ymin_, ymax_); for (BuffersIterator<float> it = output->iterate_with(inputs, area); !it.is_end(); ++it) { - if (BLI_rcti_isect_pt(&crop_area, it.x, it.y)) { + if ((it.x < xmax_ && it.x >= xmin_) && (it.y < ymax_ && it.y >= ymin_)) { copy_v4_v4(it.out, it.in(0)); } else { @@ -166,11 +164,11 @@ void CropImageOperation::update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span<MemoryBuffer *> inputs) { - rcti op_area; - BLI_rcti_init(&op_area, 0, get_width(), 0, get_height()); const MemoryBuffer *input = inputs[0]; + const int width = get_width(); + const int height = get_height(); for (BuffersIterator<float> it = output->iterate_with({}, area); !it.is_end(); ++it) { - if (BLI_rcti_isect_pt(&op_area, it.x, it.y)) { + if (it.x >= 0 && it.x < width && it.y >= 0 && it.y < height) { input->read_elem_checked(it.x + xmin_, it.y + ymin_, it.out); } else { |