summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-08-30 17:22:28 +0300
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-09-05 16:29:33 +0300
commit6d474717673530d6e4160fa251bbf226d301f1f1 (patch)
treed1ac949537de2ceb1e0a9fd148be7a904e3cd399 /platform
parent89eb23e6b5e5cef2a8f3c1c8e2f76cce76a895b6 (diff)
downloadqtlocation-mapboxgl-6d474717673530d6e4160fa251bbf226d301f1f1.tar.gz
[ios] extend ui image additions with init from premultiplied image
Diffstat (limited to 'platform')
-rw-r--r--platform/ios/src/UIImage+MGLAdditions.h2
-rw-r--r--platform/ios/src/UIImage+MGLAdditions.mm13
2 files changed, 15 insertions, 0 deletions
diff --git a/platform/ios/src/UIImage+MGLAdditions.h b/platform/ios/src/UIImage+MGLAdditions.h
index 6e15e07cb5..3c179d6324 100644
--- a/platform/ios/src/UIImage+MGLAdditions.h
+++ b/platform/ios/src/UIImage+MGLAdditions.h
@@ -8,6 +8,8 @@ NS_ASSUME_NONNULL_BEGIN
- (nullable instancetype)initWithMGLStyleImage:(const mbgl::style::Image *)styleImage;
+- (nullable instancetype)initWithMGLPremultipliedImage:(const mbgl::PremultipliedImage&&)mbglImage;
+
- (std::unique_ptr<mbgl::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier;
- (mbgl::PremultipliedImage)mgl_premultipliedImage;
diff --git a/platform/ios/src/UIImage+MGLAdditions.mm b/platform/ios/src/UIImage+MGLAdditions.mm
index 5e28d18190..7cf1ed9bcc 100644
--- a/platform/ios/src/UIImage+MGLAdditions.mm
+++ b/platform/ios/src/UIImage+MGLAdditions.mm
@@ -22,6 +22,19 @@
return self;
}
+- (nullable instancetype)initWithMGLPremultipliedImage:(const mbgl::PremultipliedImage&&)mbglImage
+{
+ CGImageRef image = CGImageFromMGLPremultipliedImage(mbglImage.clone());
+ if (!image) {
+ return nil;
+ }
+
+ self = [self initWithCGImage:image scale:1.0 orientation:UIImageOrientationUp];
+
+ CGImageRelease(image);
+ return self;
+}
+
- (std::unique_ptr<mbgl::style::Image>)mgl_styleImageWithIdentifier:(NSString *)identifier {
BOOL isTemplate = self.renderingMode == UIImageRenderingModeAlwaysTemplate;
return std::make_unique<mbgl::style::Image>([identifier UTF8String],