Files
test/source/blender/imbuf/intern/interp.cc
Omar Emara 2906ea9785 BLI: Add nearest interpolation with clamped boundary
This patch adds clamped boundaries variants of the nearest interpolation
functions in the BLI module. The naming convention used by the bilinear
functions were followed.

Needed by #119414.

Pull Request: https://projects.blender.org/blender/blender/pulls/119732
2024-03-21 13:22:10 +01:00

28 lines
729 B
C++

/* SPDX-FileCopyrightText: 2024 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup imbuf
*/
#include "BLI_math_vector.h"
#include "IMB_colormanagement.hh"
#include "IMB_interp.hh"
void IMB_sampleImageAtLocation(ImBuf *ibuf, float x, float y, bool make_linear_rgb, float color[4])
{
using namespace blender;
if (ibuf->float_buffer.data) {
imbuf::interpolate_nearest_border_fl(ibuf, color, x, y);
}
else {
uchar4 byte_color = imbuf::interpolate_nearest_border_byte(ibuf, x, y);
rgba_uchar_to_float(color, byte_color);
if (make_linear_rgb) {
IMB_colormanagement_colorspace_to_scene_linear_v4(
color, false, ibuf->byte_buffer.colorspace);
}
}
}