use CoreImage for decoding/encoding images on osx/ios

This commit is contained in:
Konstantin Käfer
2014-10-29 19:58:34 -04:00
parent 7a13db9a86
commit e3bc69b7e7
12 changed files with 181 additions and 29 deletions

View File

@@ -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);
}
}