2022-02-12 04:08:09 +00:00
|
|
|
import pixie/common, pixie/fileformats/bmp, random, strformat, flatty/binny, os
|
|
|
|
|
|
|
|
randomize()
|
|
|
|
|
2022-02-12 05:08:24 +00:00
|
|
|
var originals = @["tests/fileformats/bmp/knight.32.bmp"]
|
2022-02-12 04:08:09 +00:00
|
|
|
for file in walkFiles("tests/fileformats/bmp/bmpsuite/*"):
|
2022-02-12 05:08:24 +00:00
|
|
|
originals.add(file)
|
2022-02-12 04:08:09 +00:00
|
|
|
|
2022-02-12 05:08:24 +00:00
|
|
|
for i in 0 ..< 1000:
|
|
|
|
let file = originals[rand(originals.len-1)]
|
|
|
|
var data = readFile(file)
|
2022-02-12 04:08:09 +00:00
|
|
|
let
|
|
|
|
pos = rand(data.len-1)
|
|
|
|
value = rand(255).char
|
|
|
|
# pos = 27355
|
|
|
|
# value = '&'
|
|
|
|
data[pos] = value
|
|
|
|
|
|
|
|
let
|
|
|
|
width = data.readInt32(18).int
|
|
|
|
height = data.readInt32(22).int
|
2022-02-12 05:08:24 +00:00
|
|
|
if abs(width) > 1000 or abs(height) > 1000:
|
2022-02-12 04:08:09 +00:00
|
|
|
echo "too big"
|
|
|
|
continue
|
|
|
|
|
2022-02-12 05:08:24 +00:00
|
|
|
echo &"{i} {file} {pos} {repr(value)}"
|
2022-02-12 04:08:09 +00:00
|
|
|
try:
|
|
|
|
let img = decodeBmp(data)
|
|
|
|
doAssert img.height > 0 and img.width > 0
|
|
|
|
except PixieError:
|
|
|
|
discard
|
|
|
|
|
|
|
|
data = data[0 ..< pos]
|
|
|
|
try:
|
|
|
|
let img = decodeBmp(data)
|
|
|
|
doAssert img.height > 0 and img.width > 0
|
|
|
|
except PixieError:
|
|
|
|
discard
|