You could first draw a masking bitmap with OR logic (mode 0), and then draw the graphics bitmap with XOR logic (mode 1). Any bit that's set in both bitmaps will show up white, any bit that's set in the first and not in the second will show up black, and any bit that isn't set in either is "transparent."