summaryrefslogtreecommitdiffhomepage
path: root/wall-tileset-tool
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-11-30 04:46:57 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-11-30 04:46:57 +0100
commit37cfaa7cee2dcd32e7c7305056e224e87e752ebe (patch)
tree7704729c46dca967e6974410c2fbed8d4a5d6e02 /wall-tileset-tool
parent0ab9fd3c4642f3361d32fabc67d393f13d4f222f (diff)
a
Diffstat (limited to 'wall-tileset-tool')
-rw-r--r--wall-tileset-tool/main.cpp11
-rw-r--r--wall-tileset-tool/main.hpp1
2 files changed, 11 insertions, 1 deletions
diff --git a/wall-tileset-tool/main.cpp b/wall-tileset-tool/main.cpp
index aba79a31..d616324b 100644
--- a/wall-tileset-tool/main.cpp
+++ b/wall-tileset-tool/main.cpp
@@ -124,7 +124,14 @@ bool save_image(state st)
src.copyTo(st.dest(rect));
}
auto filename = ""_s.join({Path::join(st.opts.output_dir, st.new_atlas.header.name), ".png"_s});
- cv::imwrite(filename, st.dest);
+ if (!st.opts.use_alpha)
+ {
+ cv::Mat3b img;
+ cv::cvtColor(st.dest, img, cv::COLOR_BGRA2BGR);
+ cv::imwrite(filename, img);
+ }
+ else
+ cv::imwrite(filename, st.dest);
return true;
}
@@ -196,6 +203,8 @@ bool do_group(state st, size_t i, size_t j, Group& new_group)
}
cv::Mat4b buf;
+ if (mat.channels() == 4)
+ st.opts.use_alpha = true;
if (!convert_to_bgra32(mat, buf)) [[unlikely]]
{
ERR << "fatal: unknown image pixel format:"
diff --git a/wall-tileset-tool/main.hpp b/wall-tileset-tool/main.hpp
index 9a653ba7..7584797a 100644
--- a/wall-tileset-tool/main.hpp
+++ b/wall-tileset-tool/main.hpp
@@ -8,6 +8,7 @@ namespace floormat::wall_tool {
struct options
{
String input_dir, input_file, output_dir;
+ bool use_alpha = false;
};
struct frame