File indexing completed on 2024-05-12 16:28:12

0001 // SPDX-FileCopyrightText: 2022 DeepBlueV7.X <https://github.com/deepbluev7>
0002 // SPDX-License-Identifier: BSL-1.0
0003 
0004 #pragma once
0005 
0006 #include <string>
0007 #include <string_view>
0008 #include <vector>
0009 
0010 namespace blurhash {
0011 struct Image
0012 {
0013         size_t width, height;
0014         std::vector<unsigned char> image; // pixels rgb
0015 };
0016 
0017 // Decode a blurhash to an image with size width*height
0018 Image
0019 decode(std::string_view blurhash, size_t width, size_t height, size_t bytesPerPixel = 3) noexcept;
0020 
0021 // Encode an image of rgb pixels (without padding) with size width*height into a blurhash with x*y
0022 // components
0023 std::string
0024 encode(unsigned char *image, size_t width, size_t height, int x, int y);
0025 }