[macos] Fixed compilation error (#6690)
Followup to last-minute refactoring in #6637.
This commit is contained in:
@@ -2,14 +2,13 @@
|
||||
|
||||
@implementation NSImage (MGLAdditions)
|
||||
|
||||
- (std::unique_ptr<mbgl::SpriteImage>)mgl_spriteImage
|
||||
{
|
||||
- (std::unique_ptr<mbgl::SpriteImage>)mgl_spriteImage {
|
||||
// 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
|
||||
[image lockFocus];
|
||||
[self lockFocus];
|
||||
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:{ NSZeroPoint, self.size }];
|
||||
[image unlockFocus];
|
||||
[self unlockFocus];
|
||||
|
||||
// Get the image’s raw pixel data as an RGBA buffer.
|
||||
std::string pixelString((const char *)rep.bitmapData, rep.pixelsWide * rep.pixelsHigh * 4 /* RGBA */);
|
||||
@@ -17,7 +16,7 @@
|
||||
mbgl::PremultipliedImage cPremultipliedImage(rep.pixelsWide, rep.pixelsHigh);
|
||||
std::copy(rep.bitmapData, rep.bitmapData + cPremultipliedImage.size(), cPremultipliedImage.data.get());
|
||||
return std::make_unique<mbgl::SpriteImage>(std::move(cPremultipliedImage),
|
||||
(float)(rep.pixelsWide / self.size.width));
|
||||
(float)(rep.pixelsWide / self.size.width));
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user