summary refs log tree commit diff
path: root/third_party
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-03-04 01:30:43 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2020-03-04 01:30:43 +0100
commit5ac18f1f5f758c28316791dc9aed8e216291dd38 (patch)
tree2c78f8c45b5da9b35cb91b01069b053593527769 /third_party
parentExperimental blurhash implementation (MXC2448) (diff)
downloadnheko-5ac18f1f5f758c28316791dc9aed8e216291dd38.tar.xz
Speed up blurhash code
Diffstat (limited to 'third_party')
-rw-r--r--third_party/blurhash/blurhash.cpp5
-rw-r--r--third_party/blurhash/blurhash.hpp2
2 files changed, 5 insertions, 2 deletions
diff --git a/third_party/blurhash/blurhash.cpp b/third_party/blurhash/blurhash.cpp
index 0ff6cb74..cd0a18a4 100644
--- a/third_party/blurhash/blurhash.cpp
+++ b/third_party/blurhash/blurhash.cpp
@@ -251,7 +251,7 @@ multiplyBasisFunction(Components components, int width, int height, unsigned cha
 
 namespace blurhash {
 Image
-decode(std::string_view blurhash, size_t width, size_t height)
+decode(std::string_view blurhash, size_t width, size_t height, size_t bytesPerPixel)
 {
         Image i{};
 
@@ -295,6 +295,9 @@ decode(std::string_view blurhash, size_t width, size_t height)
                         i.image.push_back(static_cast<unsigned char>(linearToSrgb(c.r)));
                         i.image.push_back(static_cast<unsigned char>(linearToSrgb(c.g)));
                         i.image.push_back(static_cast<unsigned char>(linearToSrgb(c.b)));
+
+                        for (size_t p = 3; p < bytesPerPixel; p++)
+                                i.image.push_back(255);
                 }
         }
 
diff --git a/third_party/blurhash/blurhash.hpp b/third_party/blurhash/blurhash.hpp
index 5077f0d5..e01b9b3f 100644
--- a/third_party/blurhash/blurhash.hpp
+++ b/third_party/blurhash/blurhash.hpp
@@ -13,7 +13,7 @@ struct Image
 
 // Decode a blurhash to an image with size width*height
 Image
-decode(std::string_view blurhash, size_t width, size_t height);
+decode(std::string_view blurhash, size_t width, size_t height, size_t bytesPerPixel = 3);
 
 // Encode an image of rgb pixels (without padding) with size width*height into a blurhash with x*y
 // components