@@ -38,7 +38,6 @@ function decode83(str as string) as integer
38
38
end function
39
39
40
40
function isBlurhashValid (blurhash as string ) as boolean
41
-
42
41
if blurhash = invalid or len (blurhash ) < 6
43
42
print "The blurhash string must be at least 6 characters"
44
43
return false
@@ -120,16 +119,19 @@ end function
120
119
' the images in the fs are named with a hash of the blurhash string
121
120
' so that items which already exist are not rendered twice
122
121
function renderFakeBlurhash (blurhash as string , width as integer , height as integer , punch = 1 as float )
123
- bhfn = CreateObject ("roByteArray " )
124
- bhfn .FromAsciiString (blurhash )
122
+ ' determine the file name
123
+ ' create the hasher and the bytestring for the hasher
124
+ blurhashByteArray = CreateObject ("roByteArray " )
125
+ blurhashByteArray .FromAsciiString (blurhash )
125
126
digest = CreateObject ("roEVPDigest " )
126
127
digest .Setup ("md5" )
127
- digest .Update (bhfn )
128
- fn = digest .Final ()
128
+ digest .Update (blurhashByteArray )
129
+ filename = digest .Final ()
129
130
localFileSystem = CreateObject ("roFileSystem " )
130
- if localFileSystem .Exists ("tmp://" + fn + ".bmp" )
131
- return "tmp://" + fn + ".bmp"
131
+ if localFileSystem .Exists ("tmp://" + filename + ".bmp" )
132
+ return "tmp://" + filename + ".bmp"
132
133
end if
134
+ ' doesn't exist in fs. render it.
133
135
if isBlurhashValid (blurhash ) = false then return invalid
134
136
sizeFlag = decode83 (Mid (blurhash , 1 , 1 ))
135
137
numY = Fix (sizeFlag / 9 ) + 1
@@ -175,6 +177,6 @@ function renderFakeBlurhash(blurhash as string, width as integer, height as inte
175
177
pixels .push (pixel )
176
178
end for
177
179
ba = bitmapImageByteArray (numX , numY , pixels )
178
- ba .WriteFile ("tmp://" + fn + ".bmp" )
179
- return "tmp://" + fn + ".bmp"
180
+ ba .WriteFile ("tmp://" + filename + ".bmp" )
181
+ return "tmp://" + filename + ".bmp"
180
182
end function
0 commit comments