Blender V4.3
IMB_interp.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11
12#pragma once
13
14#include "BLI_math_interp.hh"
15#include "IMB_imbuf_types.hh"
16
17#include <cstring>
18
19namespace blender::imbuf {
20
21/* Nearest sampling. */
22
23[[nodiscard]] inline uchar4 interpolate_nearest_border_byte(const ImBuf *in, float u, float v)
24{
26}
27[[nodiscard]] inline float4 interpolate_nearest_border_fl(const ImBuf *in, float u, float v)
28{
29 return math::interpolate_nearest_border_fl(in->float_buffer.data, in->x, in->y, u, v);
30}
31inline void interpolate_nearest_border_byte(const ImBuf *in, uchar output[4], float u, float v)
32{
34}
35inline void interpolate_nearest_border_fl(const ImBuf *in, float output[4], float u, float v)
36{
38}
39
40/* Nearest sampling with UV wrapping. */
41
42[[nodiscard]] inline uchar4 interpolate_nearest_wrap_byte(const ImBuf *in, float u, float v)
43{
44 return math::interpolate_nearest_wrap_byte(in->byte_buffer.data, in->x, in->y, u, v);
45}
46[[nodiscard]] inline float4 interpolate_nearest_wrap_fl(const ImBuf *in, float u, float v)
47{
48 return math::interpolate_nearest_wrap_fl(in->float_buffer.data, in->x, in->y, u, v);
49}
50
51/* Bilinear sampling. */
52
53[[nodiscard]] inline uchar4 interpolate_bilinear_byte(const ImBuf *in, float u, float v)
54{
55 return math::interpolate_bilinear_byte(in->byte_buffer.data, in->x, in->y, u, v);
56}
57[[nodiscard]] inline float4 interpolate_bilinear_fl(const ImBuf *in, float u, float v)
58{
59 return math::interpolate_bilinear_fl(in->float_buffer.data, in->x, in->y, u, v);
60}
61inline void interpolate_bilinear_byte(const ImBuf *in, uchar output[4], float u, float v)
62{
64 memcpy(output, &col, sizeof(col));
65}
66inline void interpolate_bilinear_fl(const ImBuf *in, float output[4], float u, float v)
67{
69 memcpy(output, &col, sizeof(col));
70}
71
72/* Bilinear sampling, samples near edge blend into transparency. */
73
74[[nodiscard]] inline uchar4 interpolate_bilinear_border_byte(const ImBuf *in, float u, float v)
75{
77}
78[[nodiscard]] inline float4 interpolate_bilinear_border_fl(const ImBuf *in, float u, float v)
79{
81}
82inline void interpolate_bilinear_border_byte(const ImBuf *in, uchar output[4], float u, float v)
83{
85 memcpy(output, &col, sizeof(col));
86}
87inline void interpolate_bilinear_border_fl(const ImBuf *in, float output[4], float u, float v)
88{
90 memcpy(output, &col, sizeof(col));
91}
92
93/* Bilinear sampling with UV wrapping. */
94
95[[nodiscard]] inline uchar4 interpolate_bilinear_wrap_byte(const ImBuf *in, float u, float v)
96{
97 return math::interpolate_bilinear_wrap_byte(in->byte_buffer.data, in->x, in->y, u, v);
98}
99[[nodiscard]] inline float4 interpolate_bilinear_wrap_fl(const ImBuf *in, float u, float v)
100{
101 return math::interpolate_bilinear_wrap_fl(in->float_buffer.data, in->x, in->y, u, v);
102}
103
104/* Cubic B-Spline sampling. */
105
106[[nodiscard]] inline uchar4 interpolate_cubic_bspline_byte(const ImBuf *in, float u, float v)
107{
108 return math::interpolate_cubic_bspline_byte(in->byte_buffer.data, in->x, in->y, u, v);
109}
110[[nodiscard]] inline float4 interpolate_cubic_bspline_fl(const ImBuf *in, float u, float v)
111{
112 return math::interpolate_cubic_bspline_fl(in->float_buffer.data, in->x, in->y, u, v);
113}
114inline void interpolate_cubic_bspline_byte(const ImBuf *in, uchar output[4], float u, float v)
115{
117 memcpy(output, &col, sizeof(col));
118}
119inline void interpolate_cubic_bspline_fl(const ImBuf *in, float output[4], float u, float v)
120{
122 memcpy(output, &col, sizeof(col));
123}
124
125/* Cubic Mitchell sampling. */
126
127[[nodiscard]] inline uchar4 interpolate_cubic_mitchell_byte(const ImBuf *in, float u, float v)
128{
129 return math::interpolate_cubic_mitchell_byte(in->byte_buffer.data, in->x, in->y, u, v);
130}
131inline void interpolate_cubic_mitchell_byte(const ImBuf *in, uchar output[4], float u, float v)
132{
134 memcpy(output, &col, sizeof(col));
135}
136
137} // namespace blender::imbuf
138
143 ImBuf *ibuf, float x, float y, bool make_linear_rgb, float color[4]);
unsigned char uchar
Contains defines and structs used throughout the imbuf module.
void IMB_sampleImageAtLocation(ImBuf *ibuf, float x, float y, bool make_linear_rgb, float color[4])
Definition interp.cc:13
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
ATTR_WARN_UNUSED_RESULT const BMVert * v
#define output
uint col
float4 interpolate_nearest_border_fl(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:27
float4 interpolate_bilinear_fl(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:57
uchar4 interpolate_nearest_wrap_byte(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:42
uchar4 interpolate_bilinear_wrap_byte(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:95
uchar4 interpolate_nearest_border_byte(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:23
uchar4 interpolate_bilinear_byte(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:53
uchar4 interpolate_cubic_mitchell_byte(const ImBuf *in, float u, float v)
uchar4 interpolate_cubic_bspline_byte(const ImBuf *in, float u, float v)
float4 interpolate_nearest_wrap_fl(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:46
float4 interpolate_cubic_bspline_fl(const ImBuf *in, float u, float v)
uchar4 interpolate_bilinear_border_byte(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:74
float4 interpolate_bilinear_wrap_fl(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:99
float4 interpolate_bilinear_border_fl(const ImBuf *in, float u, float v)
Definition IMB_interp.hh:78
uchar4 interpolate_cubic_mitchell_byte(const uchar *buffer, int width, int height, float u, float v)
void interpolate_nearest_wrap_fl(const float *buffer, float *output, int width, int height, int components, float u, float v)
uchar4 interpolate_bilinear_wrap_byte(const uchar *buffer, int width, int height, float u, float v)
uchar4 interpolate_bilinear_byte(const uchar *buffer, int width, int height, float u, float v)
void interpolate_nearest_border_fl(const float *buffer, float *output, int width, int height, int components, float u, float v)
float4 interpolate_bilinear_border_fl(const float *buffer, int width, int height, float u, float v)
float4 interpolate_bilinear_wrap_fl(const float *buffer, int width, int height, float u, float v)
float4 interpolate_cubic_bspline_fl(const float *buffer, int width, int height, float u, float v)
float4 interpolate_bilinear_fl(const float *buffer, int width, int height, float u, float v)
void interpolate_nearest_wrap_byte(const uchar *buffer, uchar *output, int width, int height, float u, float v)
uchar4 interpolate_cubic_bspline_byte(const uchar *buffer, int width, int height, float u, float v)
uchar4 interpolate_bilinear_border_byte(const uchar *buffer, int width, int height, float u, float v)
void interpolate_nearest_border_byte(const uchar *buffer, uchar *output, int width, int height, float u, float v)
blender::VecBase< uint8_t, 4 > uchar4
VecBase< float, 4 > float4
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer