ws-tex: image/pcx (read 1/2/4/8-bit, planes, palettes; write 8-bit palette / 24 / 32-bit RLE)

Tested against netpbm ppmtopcx / ImageMagick / Pillow files decoded by pcxtoppm; our files read by
ImageMagick. Shared test helper tests/image/_raster.luau and fixture helper tools/fixtures/_raster_ref.py.
This commit is contained in:
4DBug committed 2026-10-31 14:48:46 -05:00
1 parent abd01270f0
commit d294c211f9
8 files changed
+614

No files matched your search

+38
View File
@@ -108,3 +108,41 @@ if which == "exr" then
emit("ours_rgb_zip.exr", Exr.encode(opaque))
emit("ours_from_rgba8.exr", Exr.encode(image(16, 16, "rgba8", 2)))
end
-- the simple raster writers: a 37 x 23 photo-like image (opaque and with alpha) and a 12-colour one
local function photo(alpha: boolean): Types.Image
local img = image(37, 23, "rgba8", 0)
if not alpha then
for i = 0, 37 * 23 - 1 do
buffer.writeu8(img.pixels, i * 4 + 3, 255)
end
end
return img
end
local function few(): Types.Image
local img = Types.Image.new(30, 20)
for y = 0, 19 do
for x = 0, 29 do
local k = (x // 3 + y // 2) % 12
buffer.writeu32(img.pixels, (y * 30 + x) * 4, (k * 20) + (255 - k * 20) * 256 + ((k * 77) % 256) * 65536 + 0xFF000000)
end
end
return img
end
local function simple(): any
if which == "pcx" then
return require("@formats/image/pcx")
end
return nil
end
local Fmt = simple()
if Fmt then
for name, img in { opaque = photo(false), alpha = photo(true), few = few() } do
local out, err = Fmt.encode(img)
if out then
emit("ours_" .. name .. "." .. which, out)
else
print("skip\t" .. name .. "\t" .. tostring(err))
end
end
end