| 1 | #pragma once |
| 2 | |
| 3 | #include <string> |
| 4 | #include <string_view> |
| 5 | #include <vector> |
| 6 | |
| 7 | namespace blurhash { |
| 8 | struct Image |
| 9 | { |
| 10 | size_t width, height; |
| 11 | std::vector<unsigned char> image; // pixels rgb |
| 12 | }; |
| 13 | |
| 14 | // Decode a blurhash to an image with size width*height |
| 15 | Image |
| 16 | decode(std::string_view blurhash, size_t width, size_t height, size_t bytesPerPixel = 3) noexcept; |
| 17 | |
| 18 | // Encode an image of rgb pixels (without padding) with size width*height into a blurhash with x*y |
| 19 | // components |
| 20 | std::string |
| 21 | encode(unsigned char *image, size_t width, size_t height, int x, int y); |
| 22 | } |