I just realized that the 127 and 128 values are swapped in the last equation above. It should be the following instead:
Mind you, I highly doubt anyone would ever be able to see the difference, but the above is the correct equation.
Code:
alpha = transA + (alpha - 128) * (255 - transA) / 127;
Mind you, I highly doubt anyone would ever be able to see the difference, but the above is the correct equation.