2020-11-20 19:13:18 +00:00
|
|
|
import pixie, pixie/fileformats/bmp, chroma
|
2020-11-20 17:14:33 +00:00
|
|
|
|
|
|
|
block:
|
|
|
|
var image = newImage(4, 2)
|
|
|
|
|
|
|
|
image[0, 0] = rgba(0, 0, 255, 255)
|
|
|
|
image[1, 0] = rgba(0, 255, 0, 255)
|
|
|
|
image[2, 0] = rgba(255, 0, 0, 255)
|
|
|
|
image[3, 0] = rgba(255, 255, 255, 255)
|
|
|
|
|
|
|
|
image[0, 1] = rgba(0, 0, 255, 127)
|
|
|
|
image[1, 1] = rgba(0, 255, 0, 127)
|
|
|
|
image[2, 1] = rgba(255, 0, 0, 127)
|
|
|
|
image[3, 1] = rgba(255, 255, 255, 127)
|
|
|
|
|
2020-11-20 18:00:58 +00:00
|
|
|
writeFile("tests/images/bmp/test4x2.bmp", encodeBmp(image))
|
2020-11-20 17:14:33 +00:00
|
|
|
|
|
|
|
var image2 = decodeBmp(encodeBmp(image))
|
|
|
|
doAssert image2.width == image.width
|
|
|
|
doAssert image2.height == image.height
|
|
|
|
doAssert image2.data == image.data
|
|
|
|
|
|
|
|
block:
|
|
|
|
var image = newImage(16, 16)
|
2020-11-23 20:09:11 +00:00
|
|
|
image = image.fill(rgba(255, 0, 0, 127))
|
2020-11-20 18:00:58 +00:00
|
|
|
writeFile("tests/images/bmp/test16x16.bmp", encodeBmp(image))
|
2020-11-20 17:14:33 +00:00
|
|
|
|
|
|
|
var image2 = decodeBmp(encodeBmp(image))
|
|
|
|
doAssert image2.width == image.width
|
|
|
|
doAssert image2.height == image.height
|
|
|
|
doAssert image2.data == image.data
|
2020-11-20 17:56:34 +00:00
|
|
|
|
|
|
|
block:
|
|
|
|
for bits in [32, 24]:
|
2020-11-20 18:00:58 +00:00
|
|
|
var image = decodeBmp(readFile("tests/images/bmp/knight." & $bits & ".master.bmp"))
|
|
|
|
writeFile("tests/images/bmp/knight." & $bits & ".bmp", encodeBmp(image))
|