Input and output formats must be the same, the overlay format must be the same as the input except possibly with an additional alpha component.