Preventing index out of range error if increasing block size

This commit is contained in:
Paul-Christian Volkmer 2022-02-24 18:19:56 +01:00
parent 80d97f6307
commit 53a95b1d50
2 changed files with 2 additions and 3 deletions

View File

@ -10,7 +10,7 @@ HTTP `GET` is used to request an identicon image.
curl http://localhost:8000/avatar/23463b99b62a72f26ed677cc556c44e8?s=100&c=v2
....
Instead of requesting identicons for MD5 hashes of usernames or mail addresses, it is possible to use plain username and mail address. The will result in the same generated identicon.
Instead of requesting identicons for MD5 hashes of usernames or mail addresses, it is possible to use plain username and mail address. This will result in the same generated identicon.
Use request query parameter `s` to request images with specified size. Default value is 80px. The size is limited to a maximum value of 512px.

View File

@ -40,7 +40,6 @@ func genGhIcon(id string, size int, f func([16]byte) color.RGBA) *image.NRGBA {
if size > 512 {
size = 512
}
blocks := 5
hash := hashBytes(id)
@ -52,7 +51,7 @@ func genGhIcon(id string, size int, f func([16]byte) color.RGBA) *image.NRGBA {
ni := x + blocks*(blocks-y-1)
if x+blocks*y > 2*blocks {
di := (x + blocks*y) - 2*blocks
data[di] = nibbles[ni]%2 == 0
data[di] = nibbles[ni%32]%2 == 0
}
}
}