2021-02-14 18:27:32 +00:00
|
|
|
import chroma, pixie/fileformats/png, pngsuite, stb_image/read as stbi, strformat
|
2020-11-21 02:21:27 +00:00
|
|
|
|
|
|
|
for file in pngSuiteFiles:
|
|
|
|
let
|
2021-10-03 22:49:21 +00:00
|
|
|
data = readFile(&"tests/fileformats/png/pngsuite/{file}.png")
|
2022-06-15 17:20:48 +00:00
|
|
|
pixieLoaded = decodePng(data)
|
2020-11-21 02:21:27 +00:00
|
|
|
|
|
|
|
var
|
|
|
|
width, height, channels: int
|
|
|
|
stbiLoadedData = loadFromMemory(
|
|
|
|
cast[seq[byte]](data),
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
channels,
|
|
|
|
stbi.RGBA
|
|
|
|
)
|
|
|
|
stbiLoadedRGBA: seq[ColorRGBA]
|
|
|
|
|
|
|
|
var i: int
|
|
|
|
while i < stbiLoadedData.len:
|
|
|
|
stbiLoadedRGBA.add(ColorRGBA(
|
|
|
|
r: stbiLoadedData[i + 0],
|
|
|
|
g: stbiLoadedData[i + 1],
|
|
|
|
b: stbiLoadedData[i + 2],
|
|
|
|
a: stbiLoadedData[i + 3]
|
|
|
|
))
|
|
|
|
i += 4
|
|
|
|
|
|
|
|
doAssert pixieLoaded.width == width
|
|
|
|
doAssert pixieLoaded.height == height
|
|
|
|
doAssert pixieLoaded.data.len == stbiLoadedRGBA.len
|
|
|
|
doAssert pixieLoaded.data == stbiLoadedRGBA
|