imgA: merge ws/imgA-simple (tga, qoi, pnm, ico, hdr)

This commit is contained in:
4DBug committed 2026-10-31 08:58:09 -05:00
commit f0f1eb6c47
23 files changed
+3293

No files matched your search

+40
View File
@@ -178,3 +178,43 @@ do
Tiff.decode(Bytes.reader(enc16))
end)
end
-- ------------------------------------------------------------------------------------------------ imgA-simple: qoi / tga / pnm / hdr
-- fixtures: tools/fixtures/qoi.py (tests/gen/qoi_bench.luau: run python3 -I tools/fixtures.py qoi first)
do
local Qoi = require("@formats/image/qoi")
local Tga = require("@formats/image/tga")
local Pnm = require("@formats/image/pnm")
local Hdr = require("@formats/image/hdr")
local Types = require("@formats/Types")
local QB = require("@tests/gen/qoi_bench")
local qd = buffer.fromstring(QB.data)
local n = QB.width * QB.height * 4
bench("qoi decode 1024x768", 5, n, function()
Qoi.decode(Bytes.reader(qd))
end)
local img = Types.Image.new(QB.width, QB.height)
img.pixels = buffer.fromstring(QB.pixels)
bench("qoi encode 1024x768", 5, n, function()
Qoi.encode(img)
end)
local tr = Tga.encode(img, { rle = true }) :: buffer
bench("tga decode rle 1024x768", 3, n, function()
Tga.decode(Bytes.reader(tr))
end)
bench("tga encode rle 1024x768", 3, n, function()
Tga.encode(img, { rle = true })
end)
local pp = Pnm.encode(img, { format = "ppm" }) :: buffer
bench("ppm decode 1024x768", 3, n, function()
Pnm.decode(Bytes.reader(pp))
end)
local f = Hdr.decode(Bytes.reader(Hdr.encode(img) :: buffer), { native = true }) :: Types.Image
local hb = Hdr.encode(f) :: buffer
bench("hdr decode rle 1024x768 (rgbaf32)", 3, n, function()
Hdr.decode(Bytes.reader(hb), { native = true })
end)
bench("hdr encode rle 1024x768", 3, n, function()
Hdr.encode(f)
end)
end