summary refs log tree commit diff
path: root/third_party/blurhash/blurhash.hpp
blob: d4e138ef8df43ec5aebd2d4ca3d2fe9baf18b874 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#pragma once

#include <string>
#include <string_view>
#include <vector>

namespace blurhash {
struct Image
{
        size_t width, height;
        std::vector<unsigned char> image; // pixels rgb
};

// Decode a blurhash to an image with size width*height
Image
decode(std::string_view blurhash, size_t width, size_t height, size_t bytesPerPixel = 3) noexcept;

// Encode an image of rgb pixels (without padding) with size width*height into a blurhash with x*y
// components
std::string
encode(unsigned char *image, size_t width, size_t height, int x, int y);
}