summaryrefslogtreecommitdiffhomepage
path: root/anim-crop-tool
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-05 06:41:59 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-05 06:41:59 +0200
commitcbfe7450f67eb9e0f7c9ef49d593f88527230a88 (patch)
treeb1b6908bc932e1833e5f9fa7f5b7699b6055ecf4 /anim-crop-tool
parentd2b9714c5ab557de69a985bdb7e4a0ab0fd95864 (diff)
a
Diffstat (limited to 'anim-crop-tool')
-rw-r--r--anim-crop-tool/atlas.cpp14
-rw-r--r--anim-crop-tool/atlas.hpp8
-rw-r--r--anim-crop-tool/main.cpp12
3 files changed, 15 insertions, 19 deletions
diff --git a/anim-crop-tool/atlas.cpp b/anim-crop-tool/atlas.cpp
index a588ff3c..8c43d64f 100644
--- a/anim-crop-tool/atlas.cpp
+++ b/anim-crop-tool/atlas.cpp
@@ -1,31 +1,29 @@
-#undef NDEBUG
-
#include "atlas.hpp"
#include "anim/serialize.hpp"
+#include "compat/assert.hpp"
-#include <cassert>
#include <filesystem>
#include <opencv2/imgcodecs.hpp>
-void anim_atlas_row::add_entry(const anim_atlas_entry& x) noexcept
+void anim_atlas_row::add_entry(const anim_atlas_entry& x)
{
auto& frame = *x.frame;
const auto& mat = x.mat;
frame.offset = {xpos, ypos};
frame.size = {mat.cols, mat.rows};
- assert(mat.rows > 0 && mat.cols > 0);
+ ASSERT(mat.rows > 0 && mat.cols > 0);
data.push_back(x);
xpos += mat.cols;
max_height = std::max(mat.rows, max_height);
}
-void anim_atlas::advance_row() noexcept
+void anim_atlas::advance_row()
{
auto& row = rows.back();
if (row.data.empty())
return;
- assert(row.xpos); assert(row.max_height);
+ ASSERT(row.xpos > 0); ASSERT(row.max_height > 0);
ypos += row.max_height;
maxx = std::max(row.xpos, maxx);
rows.push_back({{}, 0, 0, ypos});
@@ -45,7 +43,7 @@ Magnum::Vector2i anim_atlas::size() const noexcept
return {std::max(maxx, row.xpos), ypos + row.max_height};
}
-bool anim_atlas::dump(const std::filesystem::path& filename) const noexcept
+bool anim_atlas::dump(const std::filesystem::path& filename) const
{
auto sz = size();
cv::Mat4b mat(sz[1], sz[0]);
diff --git a/anim-crop-tool/atlas.hpp b/anim-crop-tool/atlas.hpp
index 5c5e918f..66bddb5d 100644
--- a/anim-crop-tool/atlas.hpp
+++ b/anim-crop-tool/atlas.hpp
@@ -20,7 +20,7 @@ struct anim_atlas_row
std::vector<anim_atlas_entry> data;
int max_height = 0, xpos = 0, ypos = 0;
- void add_entry(const anim_atlas_entry& x) noexcept;
+ void add_entry(const anim_atlas_entry& x);
};
class anim_atlas
@@ -29,9 +29,9 @@ class anim_atlas
int ypos = 0, maxx = 0;
public:
- void add_entry(const anim_atlas_entry& x) noexcept { rows.back().add_entry(x); }
- void advance_row() noexcept;
+ void add_entry(const anim_atlas_entry& x) { rows.back().add_entry(x); }
+ void advance_row();
Magnum::Vector2i offset() const noexcept;
Magnum::Vector2i size() const noexcept;
- [[nodiscard]] bool dump(const std::filesystem::path& filename) const noexcept;
+ [[nodiscard]] bool dump(const std::filesystem::path& filename) const;
};
diff --git a/anim-crop-tool/main.cpp b/anim-crop-tool/main.cpp
index ff4c9e72..600688c1 100644
--- a/anim-crop-tool/main.cpp
+++ b/anim-crop-tool/main.cpp
@@ -1,11 +1,9 @@
-#undef NDEBUG
-
#include "atlas.hpp"
#include "anim/serialize.hpp"
#include "compat/defs.hpp"
#include "compat/sysexits.hpp"
+#include "compat/assert.hpp"
-#include <cassert>
#include <cmath>
#include <cstring>
@@ -61,7 +59,7 @@ static std::tuple<cv::Vec2i, cv::Vec2i, bool> find_image_bounds(const cv::Mat4b&
}
[[nodiscard]]
-static bool load_file(anim_group& group, options& opts, anim_atlas& atlas, const path& filename) noexcept
+static bool load_file(anim_group& group, options& opts, anim_atlas& atlas, const path& filename)
{
auto mat = progn(
cv::Mat mat = cv::imread(filename.string(), cv::IMREAD_UNCHANGED);
@@ -88,12 +86,12 @@ static bool load_file(anim_group& group, options& opts, anim_atlas& atlas, const
if (opts.scale == 0.0)
{
- assert(opts.width || opts.height);
+ ASSERT(opts.width || opts.height);
if (opts.width)
opts.scale = (double)opts.width / size.width;
else
opts.scale = (double)opts.height / size.height;
- assert(opts.scale > 1e-6);
+ ASSERT(opts.scale > 1e-6);
}
const cv::Size dest_size = {
@@ -121,7 +119,7 @@ static bool load_file(anim_group& group, options& opts, anim_atlas& atlas, const
}
[[nodiscard]]
-static bool load_directory(anim_group& group, options& opts, anim_atlas& atlas) noexcept
+static bool load_directory(anim_group& group, options& opts, anim_atlas& atlas)
{
const auto input_dir = opts.input_dir/group.name;