Closed planetis-m closed 1 year ago
Potential skeleton converter from base type to Color:
template toColorArray(a): untyped =
toOpenArray(cast[ptr UncheckedArray[Color]](addr a[0]), 0, a.len*sizeof(T) div sizeof(Color) - 1)
or better:
template toColorArray(a: openArray[byte]): untyped =
toOpenArray(cast[ptr UncheckedArray[Color]](addr a[0]), 0, a.len div sizeof(Color) - 1)
internally the formula `pixels.len * sizeof(Color) is obv wrong in the first case but correct in the second