From 37cfaa7cee2dcd32e7c7305056e224e87e752ebe Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 30 Nov 2023 04:46:57 +0100 Subject: a --- wall-tileset-tool/main.cpp | 11 ++++++++++- wall-tileset-tool/main.hpp | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3