diff options
Diffstat (limited to 'test/headless.cpp')
-rw-r--r-- | test/headless.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/headless.cpp b/test/headless.cpp index 821aaa0d38..4605d7f288 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -92,13 +92,25 @@ TEST_P(HeadlessTest, render) { map.setLonLatZoom(longitude, latitude, zoom); map.setBearing(bearing); + // Run the loop. It will terminate when we don't have any further listeners. map.run(); const unsigned int w = width * pixelRatio; const unsigned int h = height * pixelRatio; - const std::string image = util::compress_png(w, h, view.readPixels().get(), true); + auto pixels = view.readPixels(); + + const int stride = w * 4; + auto tmp = std::unique_ptr<char[]>(new char[stride]()); + char *rgba = reinterpret_cast<char *>(pixels.get()); + for (int i = 0, j = height - 1; i < j; i++, j--) { + memcpy(tmp.get(), rgba + i * stride, stride); + memcpy(rgba + i * stride, rgba + j * stride, stride); + memcpy(rgba + j * stride, tmp.get(), stride); + } + + const std::string image = util::compress_png(w, h, pixels.get()); util::write_file(actual_image, image); } } |