MapLibre Native Core
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
image.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <mbgl/util/image.hpp>
5 
6 #include <string>
7 #include <utility>
8 #include <vector>
9 #include <optional>
10 
11 namespace mbgl {
12 namespace style {
13 
14 using ImageStretch = std::pair<float, float>;
15 using ImageStretches = std::vector<ImageStretch>;
16 
17 class ImageContent {
18 public:
19  float left;
20  float top;
21  float right;
22  float bottom;
23 
24  bool operator==(const ImageContent& rhs) const {
25  return left == rhs.left && top == rhs.top && right == rhs.right && bottom == rhs.bottom;
26  }
27 };
28 
29 class Image {
30 public:
33  float pixelRatio,
34  bool sdf,
35  ImageStretches stretchX = {},
36  ImageStretches stretchY = {},
37  const std::optional<ImageContent>& content = std::nullopt);
40  float pixelRatio,
41  ImageStretches stretchX = {},
42  ImageStretches stretchY = {},
43  const std::optional<ImageContent>& content = std::nullopt)
44  : Image(std::move(id), std::move(image), pixelRatio, false, std::move(stretchX), std::move(stretchY), content) {
45  }
46  Image(const Image&);
47 
48  std::string getID() const;
49 
50  const PremultipliedImage& getImage() const;
51 
53  float getPixelRatio() const;
54 
56  bool isSdf() const;
57 
59  const ImageStretches& getStretchX() const;
61  const ImageStretches& getStretchY() const;
62 
64  const std::optional<ImageContent>& getContent() const;
65 
66  class Impl;
68  explicit Image(Immutable<Impl> baseImpl_) : baseImpl(std::move(baseImpl_)) {}
69 };
70 
71 } // namespace style
72 } // namespace mbgl
bool operator==(const ImageContent &rhs) const
Definition: image.hpp:24
const std::optional< ImageContent > & getContent() const
The space where text can be fit into this image.
Image(const Image &)
const PremultipliedImage & getImage() const
const ImageStretches & getStretchX() const
Stretch area of this image.
std::string getID() const
bool isSdf() const
Whether this image should be interpreted as a signed distance field icon.
Image(Immutable< Impl > baseImpl_)
Definition: image.hpp:68
Image(std::string id, PremultipliedImage &&, float pixelRatio, bool sdf, ImageStretches stretchX={}, ImageStretches stretchY={}, const std::optional< ImageContent > &content=std::nullopt)
Image(std::string id, PremultipliedImage &&image, float pixelRatio, ImageStretches stretchX={}, ImageStretches stretchY={}, const std::optional< ImageContent > &content=std::nullopt)
Definition: image.hpp:38
float getPixelRatio() const
Pixel ratio of the sprite image.
const ImageStretches & getStretchY() const
Stretch area of this image.
Immutable< Impl > baseImpl
Definition: image.hpp:66
std::unique_ptr< Expression > image(const char *value)
std::unique_ptr< Expression > string(std::unique_ptr< Expression >, std::unique_ptr< Expression > def=nullptr)
std::vector< ImageStretch > ImageStretches
Definition: image.hpp:15
std::pair< float, float > ImageStretch
Definition: image.hpp:14
Definition: actor.hpp:15
Definition: tile_id.hpp:256