[core] Make Map.addImage tests pass (#8843)

Fix Node tests suite implementation to parse pixelRatio from style json
Premultiply images in the node binding before sending to mbgl core
This commit is contained in:
Asheem Mamoowala
2017-05-02 09:54:06 -07:00
committed by GitHub
parent 3f0c89d633
commit 5c52401d55
7 changed files with 26 additions and 6 deletions

View File

@@ -12,6 +12,7 @@
#include <mbgl/style/image.hpp>
#include <mbgl/map/backend_scope.hpp>
#include <mbgl/map/query.hpp>
#include <mbgl/util/premultiply.hpp>
#include <unistd.h>
@@ -682,8 +683,9 @@ void NodeMap::AddImage(const Nan::FunctionCallbackInfo<v8::Value>& info) {
std::unique_ptr<uint8_t[]> data = std::make_unique<uint8_t[]>(imageLength);
std::copy(imageDataBuffer, imageDataBuffer + imageLength, data.get());
mbgl::PremultipliedImage cPremultipliedImage({ imageWidth, imageHeight}, std::move(data));
mbgl::UnassociatedImage cImage({ imageWidth, imageHeight}, std::move(data));
mbgl::PremultipliedImage cPremultipliedImage = mbgl::util::premultiply(std::move(cImage));
nodeMap->map->addImage(*Nan::Utf8String(info[0]), std::make_unique<mbgl::style::Image>(std::move(cPremultipliedImage), pixelRatio));
}