[core, ios, macos] Add image accessor to MGLStyle (#7096)
* [core] Add interface to get image from sprite atlas * [tests] Add tests for Map::getImage * [ios, macos] WIP: get MGLImage for name from style * [ios, macos] Fixed -imageForName: Convert from sprite images to platform images using the existing encodePNG() function, which is also used for printing. Allow -imageForName: to return nil without an assertion failure. Added a basic test.
This commit is contained in:
@@ -394,3 +394,15 @@ TEST(Map, RemoveImage) {
|
||||
map.removeImage("test-icon");
|
||||
test::checkImage("test/fixtures/map/remove_icon", test::render(map, test.view));
|
||||
}
|
||||
|
||||
TEST(Map, GetImage) {
|
||||
MapTest test;
|
||||
|
||||
Map map(test.backend, test.view.size, 1, test.fileSource, test.threadPool, MapMode::Still);
|
||||
auto decoded = decodeImage(util::read_file("test/fixtures/sprites/default_marker.png"));
|
||||
auto image = std::make_unique<SpriteImage>(std::move(decoded), 1.0);
|
||||
|
||||
map.setStyleJSON(util::read_file("test/fixtures/api/icon_style.json"));
|
||||
map.addImage("test-icon", std::move(image));
|
||||
test::checkImage("test/fixtures/map/get_icon", map.getImage("test-icon")->image);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user