vec: bench lines (psd decode/encode, flatten, svg parse/rasterize); psd: fast 8-bit RGB/grey channel merge
This commit is contained in:
1 parent
3408cb9b6b
commit
5155ca5ba3
2 files changed
+56
No files matched your search
@@ -225,6 +225,17 @@ function Channels.toRGBA(planes: { [any]: buffer }, w: number, h: number, depth:
|
||||
local c1, c2, c3, c4 = planes[1], planes[2], planes[3], planes[4]
|
||||
local alpha = planes.alpha
|
||||
local bitmapW = (w + 7) // 8
|
||||
if depth == 8 and (mode == 3 or mode == 1) and c1 and blen(c1) >= n then
|
||||
-- the common case, without a call per sample
|
||||
local g8 = if mode == 3 and c2 and blen(c2) >= n then c2 else c1
|
||||
local b8 = if mode == 3 and c3 and blen(c3) >= n then c3 else c1
|
||||
local a8 = if alpha and blen(alpha) >= n then alpha else nil
|
||||
for i = 0, n - 1 do
|
||||
local a = if a8 then readu8(a8, i) else 255
|
||||
writeu32(out, i * 4, readu8(c1, i) + readu8(g8, i) * 256 + readu8(b8, i) * 65536 + a * 16777216)
|
||||
end
|
||||
return out
|
||||
end
|
||||
for i = 0, n - 1 do
|
||||
local r, g, b = 0, 0, 0
|
||||
if mode == 3 then
|
||||
|
||||
Reference in new issue
Block a user