From 2cebb30302f8f8b56ec766e1da4e71c4d88bb26a Mon Sep 17 00:00:00 2001 From: Dale Price Date: Thu, 13 Jun 2024 18:54:42 -0500 Subject: [PATCH] Fix off-by-one error in Swift decoder that was cutting off the right and bottom edges of decoded BlurHash images --- Swift/BlurHashDecode.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Swift/BlurHashDecode.swift b/Swift/BlurHashDecode.swift index 7fe3b398..dd06fd96 100644 --- a/Swift/BlurHashDecode.swift +++ b/Swift/BlurHashDecode.swift @@ -38,7 +38,7 @@ extension UIImage { for j in 0 ..< numY { for i in 0 ..< numX { - let basis = cos(Float.pi * Float(x) * Float(i) / Float(width)) * cos(Float.pi * Float(y) * Float(j) / Float(height)) + let basis = cos(Float.pi * Float(x) * Float(i) / Float(width - 1)) * cos(Float.pi * Float(y) * Float(j) / Float(height - 1)) let colour = colours[i + j * numX] r += colour.0 * basis g += colour.1 * basis