Misc (#19)
* get image returns optional<Mat> instead of unique_ptr<Mat> * introduce complexity * rename image load function * add example for a basic reader for binary image files * fix windows build? * add a status bar underneath the menu bar * use status bar in custom_0 example app * clang formats * packing w/ pragma push * add "Save As" functions to image views * resize over reserve * rm local override uri * add simple thread pool * rename to simple_thread_pool * get rid of useless renderlib * document version inc * extract hardcoded values to in-header * clang format patch * clone registered image in custom_0 * document binary-file header * minor fixes * clang format * rm unused render cmake
This commit is contained in:
committed by
Maximilian Kueffner
parent
e3e161ce52
commit
b37814204f
@@ -0,0 +1,32 @@
|
||||
#include "RenderHelpers.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
/// @brief Checks if the dimensions of two ImVec2 vectors have changed significantly.
|
||||
/// @param ref_rect The reference ImVec2 vector.
|
||||
/// @param new_rect The new ImVec2 vector to compare against.
|
||||
/// @return True if the absolute difference between the y-coordinates is greater than 5 or the x-coordinates are
|
||||
/// different; otherwise, false.
|
||||
bool pixelarium::application::dim_changed_p(const ImVec2& ref_rect, const ImVec2& new_rect)
|
||||
{
|
||||
if (std::abs(ref_rect.y - new_rect.y) > 5 || std::abs(ref_rect.x - new_rect.x))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// @brief Calculates dimensions to maintain aspect ratio.
|
||||
/// @param img The input image.
|
||||
/// @param curr_dim The current dimensions.
|
||||
/// @return The calculated dimensions maintaining aspect ratio.
|
||||
ImVec2 pixelarium::application::aspect_const_dimensions(const ImVec2& raw_dim, const ImVec2& curr_dim)
|
||||
{
|
||||
const auto w_fact = (curr_dim.x / raw_dim.x);
|
||||
const auto h_fact = (curr_dim.y / raw_dim.y);
|
||||
|
||||
const auto fact = w_fact < h_fact ? w_fact : h_fact;
|
||||
|
||||
return ImVec2(raw_dim.x * fact, raw_dim.y * fact);
|
||||
}
|
||||
Reference in New Issue
Block a user