[core][ios][osx][android] make SpriteImage accept PremultipliedImage

the SpriteImage constructor signature changes from

SpriteImage(
        uint16_t width, uint16_t height, float pixelRatio,
        std::string&& data, bool sdf = false);

to

SpriteImage(PremultipliedImage&&, float pixelRatio, bool sdf = false)
This commit is contained in:
Ansis Brammanis
2016-01-15 17:39:08 -08:00
parent 26faa6a5ad
commit d34f8eb674
20 changed files with 160 additions and 168 deletions

View File

@@ -2334,22 +2334,19 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration)
size_t width = CGImageGetWidth(image);
size_t height = CGImageGetHeight(image);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
std::string pixels(width * height * 4, '\0');
mbgl::PremultipliedImage cPremultipliedImage(width, height);
size_t bytesPerPixel = 4;
size_t bytesPerRow = bytesPerPixel * width;
size_t bitsPerComponent = 8;
char *pixelData = const_cast<char *>(pixels.data());
CGContextRef context = CGBitmapContextCreate(pixelData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast);
CGContextRef context = CGBitmapContextCreate(cPremultipliedImage.data.get(), width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast);
CGContextDrawImage(context, CGRectMake(0, 0, width, height), image);
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
// add sprite
auto cSpriteImage = std::make_shared<mbgl::SpriteImage>(
uint16_t(width),
uint16_t(height),
float(annotationImage.image.scale),
std::move(pixels));
std::move(cPremultipliedImage),
float(annotationImage.image.scale));
// sprite upload
NSString *symbolName = [MGLAnnotationSpritePrefix stringByAppendingString:annotationImage.reuseIdentifier];