diff options
author | Fabian Guerra <fabian.guerra@mapbox.com> | 2017-10-02 19:35:08 -0400 |
---|---|---|
committer | Fabian Guerra <fabian.guerra@mapbox.com> | 2017-10-02 19:35:08 -0400 |
commit | 6ea1e4129e5381aa6c0722797a72997a990b2710 (patch) | |
tree | e1d6d0451c1eac88a45d314dd97550268ca5fac5 | |
parent | b767c212c88cefa2917e3bcb48bf466379a521b5 (diff) | |
download | qtlocation-mapboxgl-6ea1e4129e5381aa6c0722797a72997a990b2710.tar.gz |
[macOS] Fix snapshotter 4x scaling.
-rw-r--r-- | platform/darwin/src/MGLMapSnapshotter.mm | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/platform/darwin/src/MGLMapSnapshotter.mm b/platform/darwin/src/MGLMapSnapshotter.mm index b4c1704b8d..e94ee0aaf3 100644 --- a/platform/darwin/src/MGLMapSnapshotter.mm +++ b/platform/darwin/src/MGLMapSnapshotter.mm @@ -156,11 +156,21 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; UIGraphicsEndImageContext(); #else NSImage *logoImage = [[NSImage alloc] initWithContentsOfFile:[[NSBundle mgl_frameworkBundle] pathForResource:@"mapbox" ofType:@"pdf"]]; - NSImage *compositedImage = mglImage; + NSImage *sourceImage = mglImage; + + NSSize targetSize = NSMakeSize(self.options.size.width, self.options.size.height); + NSRect targetFrame = NSMakeRect(0, 0, targetSize.width, targetSize.height); + NSImage *compositedImage = nil; + NSImageRep *sourceImageRep = [sourceImage bestRepresentationForRect:targetFrame + context:nil + hints:nil]; + compositedImage = [[NSImage alloc] initWithSize:targetSize]; [compositedImage lockFocus]; + [sourceImageRep drawInRect: targetFrame]; [logoImage drawInRect:CGRectMake(MGLLogoImagePosition.x, MGLLogoImagePosition.y, logoImage.size.width,logoImage.size.height)]; [compositedImage unlockFocus]; + #endif // Dispatch result to origin queue |