#pragma once #include #include #include namespace mbgl { enum ImageAlphaMode { Unassociated, Premultiplied }; template class Image { public: Image() = default; Image(size_t w, size_t h) : width(w), height(h), data(std::make_unique(size())) {} Image(size_t w, size_t h, std::unique_ptr data_) : width(w), height(h), data(std::move(data_)) {} bool operator==(const Image& rhs) const { return width == rhs.width && height == rhs.height && std::equal(data.get(), data.get() + size(), rhs.data.get(), rhs.data.get() + rhs.size()); } size_t stride() const { return width * 4; } size_t size() const { return width * height * 4; } size_t width = 0; size_t height = 0; std::unique_ptr data; }; using UnassociatedImage = Image; using PremultipliedImage = Image; // TODO: don't use std::string for binary data. PremultipliedImage decodeImage(const std::string&); std::string encodePNG(const PremultipliedImage&); } // namespace mbgl