2021-05-09 22:27:34 +00:00
|
|
|
import pixie, pixie/fileformats/png, pngsuite, strformat
|
2020-11-21 02:21:27 +00:00
|
|
|
|
2022-06-15 08:22:45 +00:00
|
|
|
for file in pngSuiteFiles:
|
|
|
|
let
|
|
|
|
original = readFile(&"tests/fileformats/png/pngsuite/{file}.png")
|
|
|
|
decoded = decodePng(original)
|
|
|
|
encoded = encodePng(decoded)
|
2020-11-21 02:21:27 +00:00
|
|
|
|
2021-05-09 22:27:34 +00:00
|
|
|
block:
|
|
|
|
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
|
|
|
|
2021-05-09 22:27:34 +00:00
|
|
|
for file in pngSuiteCorruptedFiles:
|
|
|
|
try:
|
2021-10-03 22:17:04 +00:00
|
|
|
discard decodePng(readFile(&"tests/fileformats/png/pngsuite/{file}.png"))
|
2021-05-09 22:27:34 +00:00
|
|
|
doAssert false
|
|
|
|
except PixieError:
|
|
|
|
discard
|
|
|
|
|
|
|
|
block:
|
2021-10-03 22:17:04 +00:00
|
|
|
discard readImage("tests/fileformats/png/trailing_data.png")
|
2022-06-09 00:53:22 +00:00
|
|
|
|
|
|
|
block:
|
|
|
|
let dimensions =
|
|
|
|
decodeImageDimensions(readFile("tests/fileformats/png/mandrill.png"))
|
|
|
|
doAssert dimensions.width == 512
|
|
|
|
doAssert dimensions.height == 512
|