Hi David,
Sorry for the late reply; forgot about my post and wasn't sure I would receive an email notification once my post was replied to.
The transparency is a fourth 'color' channel: the 'alpha' channel next to the red, green and blue channels of an individual color pixel.
The color of the pixel (r,g and b values, each having a value of 0...255) needs to be blended with the color of the pixel beneath the image containing transparency while the amount of blending depends on the 'percentage' (actually also a value of 0...255) of transparency (value of alpha channel). It's a blending of color rather than a shade of gray (eventhough a single alpha channel can be represented by a gray scale image but that's only for visualisation of the transparency 'mask').
I do not know the blending math but there is a lot to find about it on the internet; even Wikipedia covers the subject. But instead of re-inventing the wheel or figuring out the logics perhaps it's better to take advantage of other people's knowledge who are in to this matter. E.g.
www.filtermeister.com is having a users group who are on a regular basis doing all kinds of things with image effects (filtermeister is a plugin on its own that is designed to develop plugins (.8bf extension) to create image effects. filtermeister and the plugins created with it can be installed to Photoshop, Paintshop Pro, Corel PhotoPaint, Serif PhotoPlus and some more image editors supporting Adobe Photoshop compatible (8bf) plugins. In that group asking the math behind how to blend an overlaying image containing transparency with the image underneath it, should give you a usable answer by one or more group members.