summaryrefslogtreecommitdiff
path: root/src/mbgl/sprite/sprite_parser.hpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-11-05 15:05:43 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-11-12 13:03:14 -0800
commit1e350b7ea485117cadc413d4d41062cf3c3c43a1 (patch)
tree8dde92582eda347a7c88c0e655270cef82e44744 /src/mbgl/sprite/sprite_parser.hpp
parent0dc1519a1891dac6272f69dd1d1768f15908003c (diff)
downloadqtlocation-mapboxgl-1e350b7ea485117cadc413d4d41062cf3c3c43a1.tar.gz
[core] Reorganize sprite related files
Diffstat (limited to 'src/mbgl/sprite/sprite_parser.hpp')
-rw-r--r--src/mbgl/sprite/sprite_parser.hpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/mbgl/sprite/sprite_parser.hpp b/src/mbgl/sprite/sprite_parser.hpp
new file mode 100644
index 0000000000..d385d77aea
--- /dev/null
+++ b/src/mbgl/sprite/sprite_parser.hpp
@@ -0,0 +1,46 @@
+#ifndef MBGL_SPRITE_PARSER
+#define MBGL_SPRITE_PARSER
+
+#include <mapbox/variant.hpp>
+
+#include <mbgl/util/noncopyable.hpp>
+#include <mbgl/util/geo.hpp>
+
+#include <string>
+#include <memory>
+#include <map>
+
+namespace mbgl {
+
+namespace util {
+
+class Image;
+
+} // namespace util
+
+class SpriteImage;
+
+using SpriteImagePtr = std::shared_ptr<const SpriteImage>;
+
+// Extracts an individual image from a spritesheet from the given location.
+SpriteImagePtr createSpriteImage(const util::Image& image,
+ uint16_t srcX,
+ uint16_t srcY,
+ uint16_t srcWidth,
+ uint16_t srcHeight,
+ double ratio,
+ bool sdf);
+
+using Sprites = std::map<std::string, SpriteImagePtr>;
+
+
+using SpriteParseResult = mapbox::util::variant<
+ Sprites, // success
+ std::string>; // error
+
+// Parses an image and an associated JSON file and returns the sprite objects.
+SpriteParseResult parseSprite(const std::string& image, const std::string& json);
+
+} // namespace mbgl
+
+#endif