aboutsummaryrefslogtreecommitdiff
path: root/mapman/src/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mapman/src/utils.cpp')
-rw-r--r--mapman/src/utils.cpp20
1 files changed, 19 insertions, 1 deletions
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 <QColor>
#include <QImage>
+#include <QPainter>
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<uint8_t, 128 * 128> &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<uint8_t, 128 * 128> &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;
+}