diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2016-10-26 17:19:19 -0700 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2016-11-01 18:41:52 +0100 |
commit | 358701f475b2c04c4681d70435bc76370b371285 (patch) | |
tree | 7ab5d170957eb8d209716f695aec428a44d4ddf2 /include | |
parent | 9e3839781fdf1b1c6a2d61a5de9b2c7ddd68e9ed (diff) | |
download | qtlocation-mapboxgl-358701f475b2c04c4681d70435bc76370b371285.tar.gz |
[core] add ability to upload alpha-only textures + images
Diffstat (limited to 'include')
-rw-r--r-- | include/mbgl/util/image.hpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/include/mbgl/util/image.hpp b/include/mbgl/util/image.hpp index 3dbab27f41..1d84d4824a 100644 --- a/include/mbgl/util/image.hpp +++ b/include/mbgl/util/image.hpp @@ -9,9 +9,10 @@ namespace mbgl { -enum ImageAlphaMode { +enum class ImageAlphaMode { Unassociated, - Premultiplied + Premultiplied, + Exclusive, // Alpha-channel only }; template <ImageAlphaMode Mode> @@ -47,15 +48,17 @@ public: return size && data.get() != nullptr; } - size_t stride() const { return static_cast<size_t>(size.width) * 4; } + size_t stride() const { return channels * size.width; } size_t bytes() const { return stride() * size.height; } Size size; + static constexpr size_t channels = Mode == ImageAlphaMode::Exclusive ? 1 : 4; std::unique_ptr<uint8_t[]> data; }; using UnassociatedImage = Image<ImageAlphaMode::Unassociated>; using PremultipliedImage = Image<ImageAlphaMode::Premultiplied>; +using AlphaImage = Image<ImageAlphaMode::Exclusive>; // TODO: don't use std::string for binary data. PremultipliedImage decodeImage(const std::string&); |