summaryrefslogtreecommitdiff
path: root/platform/ios/src
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-12-06 00:27:41 -0800
committerMinh Nguyễn <mxn@1ec5.org>2016-12-06 16:20:14 -0800
commit88f91a48ae1b237aa285038feecf5060013baad2 (patch)
tree7f547eb06f8eb25321e97e87bf24fe8f70be1d73 /platform/ios/src
parente6d51c384d0015f4dfbabb1d3f15d84a0502b9ae (diff)
downloadqtlocation-mapboxgl-88f91a48ae1b237aa285038feecf5060013baad2.tar.gz
[ios, macos] Template images as style images
Convert template images to SDF icons and back when storing them as style images.
Diffstat (limited to 'platform/ios/src')
-rw-r--r--platform/ios/src/UIImage+MGLAdditions.mm12
1 files changed, 10 insertions, 2 deletions
diff --git a/platform/ios/src/UIImage+MGLAdditions.mm b/platform/ios/src/UIImage+MGLAdditions.mm
index 4507fb6c41..e4d072e136 100644
--- a/platform/ios/src/UIImage+MGLAdditions.mm
+++ b/platform/ios/src/UIImage+MGLAdditions.mm
@@ -6,7 +6,14 @@
{
std::string png = encodePNG(spriteImage->image);
NSData *data = [[NSData alloc] initWithBytes:png.data() length:png.size()];
- return [self initWithData:data scale:spriteImage->pixelRatio];
+ if (self = [self initWithData:data scale:spriteImage->pixelRatio])
+ {
+ if (spriteImage->sdf)
+ {
+ self = [self imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
+ }
+ }
+ return self;
}
- (std::unique_ptr<mbgl::SpriteImage>)mgl_spriteImage
@@ -28,7 +35,8 @@
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
- return std::make_unique<mbgl::SpriteImage>(std::move(cPremultipliedImage), float(self.scale));
+ BOOL isTemplate = self.renderingMode == UIImageRenderingModeAlwaysTemplate;
+ return std::make_unique<mbgl::SpriteImage>(std::move(cPremultipliedImage), float(self.scale), isTemplate);
}
@end