tests/image: comments: specs only

This commit is contained in:
4DBug committed 2026-11-01 01:50:18 -05:00
1 parent e306d5c1d7
commit a80299dce0
27 files changed
+32 -199

No files matched your search

+5 -8
View File
@@ -1,6 +1,4 @@
-- image/tim tests: PlayStation TIM files written by tools/fixtures/tim.py (4 / 8-bit CLUT, 15-bit, 24-bit) decode to
-- ImageMagick's RGB, colour 0x0000 is transparent, CLUT rows, the VRAM position; the encoder round-trips 16 / 24 /
-- 8 / 4-bit; errors; the fuzz pass.
-- image/tim tests against ImageMagick (tools/fixtures/tim.py).
local T = require("@tests/T")
local F = require("@rosetta")
local Tim = require("@rosetta/image/tim")
@@ -42,8 +40,7 @@ for _, c in Fx do
local other = Tim.decode(Bytes.reader(buffer.fromstring(c.data)), { clut = 1 }) :: any
t:check(Crc32.of(other.pixels) ~= Crc32.of(img.pixels) and other.meta.source.clut.row == 1, c.name .. ": second CLUT row")
end
-- round trips: decoded 4 / 8 / 15-bit pixels are PSX colours, so every depth that fits is lossless (24-bit only
-- round-trips as 24-bit)
-- decoded 4 / 8 / 15-bit pixels are PSX colours, so every depth that fits is lossless (24-bit only as 24-bit)
for _, bpp in (if c.bpp == 24 then { 24 } else { 16, 24, 8, 4 }) do
local enc, eerr = Tim.encode(img, { bpp = bpp })
if bpp == 24 then
@@ -68,9 +65,9 @@ end
do
local img = Types.Image.new(3, 1)
buffer.writeu32(img.pixels, 0, 0xFF000000) -- opaque black
buffer.writeu32(img.pixels, 4, 0x00FFFFFF) -- transparent
buffer.writeu32(img.pixels, 8, 0xFF0000FF) -- red
buffer.writeu32(img.pixels, 0, 0xFF000000)
buffer.writeu32(img.pixels, 4, 0x00FFFFFF)
buffer.writeu32(img.pixels, 8, 0xFF0000FF)
local back = Tim.decode(Bytes.reader(Tim.encode(img) :: buffer)) :: any
t:eq(buffer.readu32(back.pixels, 0), 0xFF000000, "opaque black stays opaque (STP)")
t:eq(buffer.readu32(back.pixels, 4), 0, "transparent")