ws-tex: docs/guide sections (textures / HDR, OpenRaster); DDS / KTX pixelFormat option; XBM / XPM names from F.save

F.save sets opts.format to the file format, so the DDS / KTX layout option is pixelFormat; XBM / XPM make a C
identifier of opts.name (F.save passes the file name).
This commit is contained in:
4DBug committed 2026-10-31 15:18:40 -05:00
1 parent d618795ce7
commit 918c8310af
10 files changed
+90 -30

No files matched your search

+3 -3
View File
@@ -163,7 +163,7 @@ do
local img = Types.Image.new(37, 23)
img.pixels = src
for _, f in { "rgba8", "bgra8" } do
local back = dec(Dds.encode(img, { format = f :: any }) :: buffer)
local back = dec(Dds.encode(img, { pixelFormat = f :: any }) :: buffer)
t:eq(buffer.tostring(back.pixels), buffer.tostring(src), f .. " round trip")
end
local f = Types.Image.new(3, 2, "rgbaf32")
@@ -172,9 +172,9 @@ do
end
local back = dec(Dds.encode(f) :: buffer, { native = true })
t:eq(buffer.tostring(back.pixels), buffer.tostring(f.pixels), "rgba32f round trip")
local _, e1 = Dds.encode(f, { format = "bc1" })
local _, e1 = Dds.encode(f, { pixelFormat = "bc1" })
t:check(e1 and e1.code == Err.ARG, "bc1 needs rgba8")
local _, e2 = Dds.encode(img, { format = "bc7" :: any })
local _, e2 = Dds.encode(img, { pixelFormat = "bc7" :: any })
t:check(e2 and e2.code == Err.ARG, "no bc7 encoder")
end
+1 -1
View File
@@ -133,7 +133,7 @@ do
end
local back = dec(Ktx.encode(f) :: buffer, { native = true })
t:eq(buffer.tostring(back.pixels), buffer.tostring(f.pixels), "rgba32f round trip")
local _, e = Ktx.encode(f, { format = "rgba8" })
local _, e = Ktx.encode(f, { pixelFormat = "rgba8" })
t:check(e and e.code == Err.ARG, "format mismatch")
local _, e2 = Ktx.encode(img, { zlib = 12 })
t:check(e2 and e2.code == Err.ARG, "zlib level")
+2 -2
View File
@@ -34,8 +34,8 @@ do
t:eq(Xbm.sniff(Bytes.reader(buffer.fromstring("#define c_width 2\n"))), 0.9, "sniff")
local _, e = Xbm.decode(Bytes.reader(buffer.fromstring("static char x[] = {};")))
t:check(e and e.code == Err.CORRUPT, "no defines")
local _, e2 = Xbm.encode(R.image(1, 1, "\0\0\0\255"), { name = "1bad" })
t:check(e2 and e2.code == Err.ARG, "bad name")
local named = Xbm.encode(R.image(1, 1, "\0\0\0\255"), { name = "1 bad.xbm" }) :: buffer
t:check(string.find(buffer.tostring(named), "#define _1_bad_width 1", 1, true) ~= nil, "name made an identifier")
end
t:fuzz("decode", function(b: buffer)
return Xbm.decode(Bytes.reader(b))