diff options
author | Langston Smith <langston.smith@mapbox.com> | 2018-01-04 11:15:50 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-04 11:15:50 -0800 |
commit | 2ea955d2751ba6459f99a0695e53505c0a11702b (patch) | |
tree | f54450918b634a2eea1bd2c4ebc671bf1bb06106 /platform/macos/src/NSImage+MGLAdditions.mm | |
parent | f2ec6ae326bad79fea2b06a21151a2835522572a (diff) | |
parent | c62b0af24fc76b4bb2eb34100611dd3ee9ee5536 (diff) | |
download | qtlocation-mapboxgl-2ea955d2751ba6459f99a0695e53505c0a11702b.tar.gz |
Merge branch 'master' into ls-android-readme-tweaksupstream/ls-android-readme-tweaks
Diffstat (limited to 'platform/macos/src/NSImage+MGLAdditions.mm')
-rw-r--r-- | platform/macos/src/NSImage+MGLAdditions.mm | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/platform/macos/src/NSImage+MGLAdditions.mm b/platform/macos/src/NSImage+MGLAdditions.mm index 6abe53e9ae..2666dfe790 100644 --- a/platform/macos/src/NSImage+MGLAdditions.mm +++ b/platform/macos/src/NSImage+MGLAdditions.mm @@ -5,7 +5,7 @@ @implementation NSImage (MGLAdditions) - (nullable instancetype)initWithMGLPremultipliedImage:(mbgl::PremultipliedImage&&)src { - CGImageRef image = CGImageFromMGLPremultipliedImage(std::move(src)); + CGImageRef image = CGImageCreateWithMGLPremultipliedImage(std::move(src)); if (!image) { return nil; } @@ -16,7 +16,7 @@ } - (nullable instancetype)initWithMGLStyleImage:(const mbgl::style::Image *)styleImage { - CGImageRef image = CGImageFromMGLPremultipliedImage(styleImage->getImage().clone()); + CGImageRef image = CGImageCreateWithMGLPremultipliedImage(styleImage->getImage().clone()); if (!image) { return nil; } @@ -42,15 +42,8 @@ } - (mbgl::PremultipliedImage)mgl_premultipliedImage { - // Create a bitmap image representation from the image, respecting backing - // scale factor and any resizing done on the image at runtime. - // http://www.cocoabuilder.com/archive/cocoa/82430-nsimage-getting-raw-bitmap-data.html#82431 - [self lockFocus]; - NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:{ NSZeroPoint, self.size }]; - [self unlockFocus]; - - mbgl::PremultipliedImage cPremultipliedImage({ static_cast<uint32_t>(rep.pixelsWide), static_cast<uint32_t>(rep.pixelsHigh) }); - std::copy(rep.bitmapData, rep.bitmapData + cPremultipliedImage.bytes(), cPremultipliedImage.data.get()); - return cPremultipliedImage; + CGImageRef ref = [self CGImageForProposedRect:nullptr context:nullptr hints:nullptr]; + return MGLPremultipliedImageFromCGImage(ref); } + @end |