2020-11-21 06:12:55 +00:00
|
|
|
import pixie/fileformats/png, strformat, pngsuite, pixie/common
|
2020-11-21 02:21:27 +00:00
|
|
|
|
|
|
|
for file in pngSuiteFiles:
|
|
|
|
let
|
2020-11-23 04:07:58 +00:00
|
|
|
original = cast[seq[uint8]](readFile(&"tests/images/pngsuite/{file}.png"))
|
2020-11-21 02:21:27 +00:00
|
|
|
decoded = decodePng(original)
|
|
|
|
encoded = encodePng(decoded)
|
|
|
|
decoded2 = decodePng(cast[seq[uint8]](encoded))
|
|
|
|
|
|
|
|
doAssert decoded.height == decoded2.height
|
|
|
|
doAssert decoded.width == decoded2.width
|
|
|
|
doAssert decoded.data == decoded2.data
|
|
|
|
|
|
|
|
for channels in 1 .. 4:
|
|
|
|
var data: seq[uint8]
|
|
|
|
for x in 0 ..< 16:
|
|
|
|
for y in 0 ..< 16:
|
|
|
|
var components = newSeq[uint8](channels)
|
|
|
|
for i in 0 ..< channels:
|
|
|
|
components[i] = (x * 16).uint8
|
|
|
|
data.add(components)
|
|
|
|
let encoded = encodePng(16, 16, channels, data[0].addr, data.len)
|
2020-11-21 06:12:55 +00:00
|
|
|
|
|
|
|
for file in pngSuiteCorruptedFiles:
|
|
|
|
try:
|
2020-11-23 04:07:58 +00:00
|
|
|
discard decodePng(readFile(&"tests/images/pngsuite/{file}.png"))
|
2020-11-21 06:12:55 +00:00
|
|
|
doAssert false
|
|
|
|
except PixieError:
|
|
|
|
discard
|