#include #include #include extern "C" { #include } namespace mbgl { PremultipliedImage decodeWebP(const uint8_t* data, size_t size) { int width = 0, height = 0; if (WebPGetInfo(data, size, &width, &height) == 0) { throw std::runtime_error("failed to retrieve WebP basic header information"); } int stride = width * 4; size_t webpSize = stride * height; auto webp = std::make_unique(webpSize); if (!WebPDecodeRGBAInto(data, size, webp.get(), webpSize, stride)) { throw std::runtime_error("failed to decode WebP data"); } UnassociatedImage image({ static_cast(width), static_cast(height) }, std::move(webp)); return util::premultiply(std::move(image)); } } // namespace mbgl