ws-cleanup-types: image/pnm, model/*: type lookup tables, table.create results and literals; casts for known values
This commit is contained in:
1 parent
7c15b02354
commit
139441a37b
23 files changed
+139
-137
No files matched your search
@@ -123,7 +123,7 @@ function Codec.pack(s: buffer, n: number, ch: number, maxval: number, invert: bo
|
||||
r, g, b, a = get(q), get(q + 1), get(q + 2), get(q + 3)
|
||||
end
|
||||
if fmt == 0 then
|
||||
writeu32(dst, i * 4, r + g * 256 + b * 65536 + a * 16777216)
|
||||
writeu32(dst, i * 4, r + g * 256 + b * 65536 + (a :: number) * 16777216)
|
||||
elseif fmt == 1 then
|
||||
writeu8(dst, i * 3, r)
|
||||
writeu8(dst, i * 3 + 1, g)
|
||||
@@ -132,12 +132,12 @@ function Codec.pack(s: buffer, n: number, ch: number, maxval: number, invert: bo
|
||||
writeu8(dst, i, r)
|
||||
elseif fmt == 3 then
|
||||
writeu8(dst, i * 2, r)
|
||||
writeu8(dst, i * 2 + 1, a)
|
||||
writeu8(dst, i * 2 + 1, a :: number)
|
||||
elseif fmt == 4 then
|
||||
writeu16(dst, i * 8, r)
|
||||
writeu16(dst, i * 8 + 2, g)
|
||||
writeu16(dst, i * 8 + 4, b)
|
||||
writeu16(dst, i * 8 + 6, a)
|
||||
writeu16(dst, i * 8 + 6, a :: number)
|
||||
elseif fmt == 5 then
|
||||
writeu16(dst, i * 2, r)
|
||||
end
|
||||
@@ -217,9 +217,9 @@ function Codec.extract(px: buffer, fmt: number, n: number, ch: number, wide: boo
|
||||
for c = 0, vals - 1 do
|
||||
local v
|
||||
if ch <= 2 then
|
||||
v = if c == 0 then gray else a
|
||||
v = if c == 0 then gray else a :: number
|
||||
else
|
||||
v = if c == 0 then r elseif c == 1 then g elseif c == 2 then b else a
|
||||
v = if c == 0 then r elseif c == 1 then g elseif c == 2 then b else a :: number
|
||||
end
|
||||
if wide and not w16 then
|
||||
v *= 257
|
||||
|
||||
Reference in new issue
Block a user