3#include <bnb/types/base_types.hpp>
4#include <bnb/utils/event.hpp>
5#include <bnb/utils/defs.hpp>
6#include <bnb/types/pixel_rect.hpp>
36 void fill_exterior(uint8_t* pixels, uint32_t width, uint32_t height, uint32_t channels,
pixel_rect rect, uint8_t color,
bool edge_repeat =
false);
61 static const int mat_s = 3;
64 using mat_t = std::array<float, mat_s * mat_s>;
80 float scale_x = 1.0f, scale_y = 1.0f;
81 float trans_x = 0.0f, trans_y = 0.0f;
83 bool flip_x =
false, flip_y =
false;
100 explicit transformation(
float scale_x,
float scale_y = 1.f,
float t_x = 0,
float t_y = 0,
rotate_t rotate = rotate_t::deg_0,
bool flip_x =
false,
bool flip_y =
false);
136 mat_t::const_pointer data() const noexcept;
142 mat_t transposed_data() const noexcept;
145 std::
string to_string() const noexcept;
148 bool is_affine() const noexcept;
152 void normalize_affine() noexcept;
163 return std::make_shared<transformation>(*
this >>
static_cast<transformation&
>(*t));
167 bool equals(
const std::shared_ptr<interfaces::transformation>& t)
const override
171 std::shared_ptr<interfaces::transformation>
inverse_j()
const override
173 return std::make_shared<transformation>(inverse());
175 std::shared_ptr<interfaces::transformation>
clone_j()
const override
177 return std::make_shared<transformation>(clone());
182 return {m.begin(), m.end()};
206 void transform(
const uint8_t* src, uint32_t src_w, uint32_t src_h, uint8_t* dst, uint32_t dst_w, uint32_t dst_h, uint32_t channels,
const transformation& t);
216 void transform(
const float* src, uint32_t src_w, uint32_t src_h,
float* dst, uint32_t dst_w, uint32_t dst_h, uint32_t channels,
const transformation& t);
229 transform(src, src_w, src_h, dst, dst_w, dst_h, channels, from.
inverse() >> to);
241 return transform(src, w, h, dst, w, h, channels, t);
void transform1x1(const uint8_t *src, uint8_t *dst, uint32_t w, uint32_t h, uint32_t channels, const transformation &t)
Transform src image to dst param src, dst source, destination image buffers param w,...
void transform(const uint8_t *src, uint32_t src_w, uint32_t src_h, uint8_t *dst, uint32_t dst_w, uint32_t dst_h, uint32_t channels, const transformation &t)
Transform src image to dst.
interfaces::point2d transform_point(const interfaces::point2d &p) const override
Apply transform to point.
void fit_rects_aspect_ratio(pixel_rect &source_rect, pixel_rect &target_rect, rect_fit_mode mode=rect_fit_mode::fit_inside)
Adjust rects to have the same aspect ratio as if fitting source_rect into target_rect according to mo...
@ fit_inside
Fit all source inside target = fit to min rect_scale of width and height modes.
@ fit_height
Always fit to height, rect_scale = h_t / h_f.
@ fit_outside
Fit to fill all target = fit to max rect_scale of width and height modes.
@ fit_width
Always fit to width, rect_scale = w_t / w_f.