From e35a90b4f45a94ab5ddf7bc9660cab451fe1a7b3 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 11 May 2024 19:53:35 -0400 Subject: (mapman) Export images. --- mapman/src/utils.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'mapman/src/utils.cpp') diff --git a/mapman/src/utils.cpp b/mapman/src/utils.cpp index e6f658c..06b0eb4 100644 --- a/mapman/src/utils.cpp +++ b/mapman/src/utils.cpp @@ -1,7 +1,10 @@ #include "utils.hpp" +#include "library.hpp" +#include "mapdump.hpp" #include #include +#include rgb_t modify_color(rgb_t c, uint8_t variant) { @@ -21,7 +24,7 @@ rgb_t modify_color(rgb_t c, uint8_t variant) QColor rgb2qcolor(rgb_t c) {return QColor(c.r, c.g, c.b);} -QPixmap pixmap_of_map_data(const std::array &map_data, double scaling) +QPixmap pixmap_of_map_data(const map_data_t &map_data, double scaling) { QImage ret(128, 128, QImage::Format_ARGB32); ret.setDevicePixelRatio(scaling); @@ -39,3 +42,18 @@ QPixmap pixmap_of_map_data(const std::array &map_data, doubl return QPixmap::fromImage(ret); } +QImage image_of_map_group(const map_library *library, const map_group_t &group, double scaling) +{ + QImage ret(group.hc * 128, group.vc * 128, QImage::Format_ARGB32); + ret.fill(0); + ret.setDevicePixelRatio(1.); + { + QPainter p(&ret); + for (int i = 0 ; i < group.vc; ++i) + for (int j = 0 ; j < group.hc; ++j) + if (group.populated[i * group.hc + j]) + p.drawPixmap(128 * j, 128 * i, pixmap_of_map_data(library->get_map(group.ids[i * group.hc + j]).map_data, 1.)); + } + ret.setDevicePixelRatio(scaling); + return ret; +} -- cgit v1.2.3