blob: d5e4a7828e52877055a629c21622d6da00825090 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include <mbgl/sprite/sprite_image.hpp>
#include <mbgl/util/exception.hpp>
#include <cmath>
namespace mbgl {
SpriteImage::SpriteImage(const uint16_t width_,
const uint16_t height_,
const float pixelRatio_,
std::string&& data_,
bool sdf_)
: width(width_),
height(height_),
pixelRatio(pixelRatio_),
pixelWidth(std::ceil(width * pixelRatio)),
pixelHeight(std::ceil(height * pixelRatio)),
data(std::move(data_)),
sdf(sdf_) {
const size_t size = pixelWidth * pixelHeight * 4;
if (size == 0) {
throw util::SpriteImageException("Sprite image dimensions may not be zero");
} else if (size != data.size()) {
throw util::SpriteImageException("Sprite image pixel count mismatch");
}
}
} // namespace mbgl
|