I am working on a basic image editing tool with support for layers, and I need to know how to merge the layers into a single image. Obviously, if the pixels have no alpha value, then whichever is on top wins, but I dont know what to do when the pixels have alpha values. So here's the question: Given two (or more) pixels represented using RGBA values, how do I merge them into a single pixel in this context (layers)?
TIA
For each component in an layer, if the alpha value is
a
(range 0..1) then you'll see a proportiona
of that component + a proportion1-a
of what's underneath.Try working from the bottom layer to the top layer.
EDIT: