When two bitmaps overlap each other

I have two bitmaps which are called A and B respectively. They overlap with each other and occupy the same 3D space, that is say, they have the same depth value. At some parts of the bitmaps, I want to see colors from A and at other parts, I want to see colors from B. I have a condition to decide at certain parts which one wins. Is there any way to do this?

try using the alpha test: glAlphaFunc(…)

The problem of glALphaFunc is how to set the reference value. Do it pixel by pixel? The winning areas of A or B are not regular shapes. It looks like the we want the alpha test to do the similar work as depth test does.