Unfortunately, you didn’t specify how you get pixels,
therefore p-code:
// The result will have its alpha chanell from "first",
// the color channells from "second".
assert (first.width = second.width)
assert (first.height = second.height)
for y in 0..height
for x in 0..width
RGBA col_first = first(x,y)
RGBA col_second = second(x,y)
result(x,y) = RGBA(col_second.r,
col_second.g,
col_second.b,
col_first.a ))
source
share