diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-10-29 19:58:34 -0400 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-10-30 12:02:28 -0400 |
commit | e3bc69b7e77aa6771c8db3695f12548447e1de51 (patch) | |
tree | 0c1a0bde928fea3e09b1d72222b400176c0936c7 /test | |
parent | 7a13db9a863c9be58709e941f44eb2c370276e2a (diff) | |
download | qtlocation-mapboxgl-e3bc69b7e77aa6771c8db3695f12548447e1de51.tar.gz |
use CoreImage for decoding/encoding images on osx/ios
Diffstat (limited to 'test')
-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 e1bdbdc061..3837beb9a0 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 - 2; 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); } } |