Search code examples
c++mfcgdi

How does bit blit work in GDI?


I'm interested in how bit blit works in gdi. I know that that it creates a resulting bitmap based on source and destination bitmaps based on dwROP parametar, but I'm interested how? I saw some example in which it is used for masking that is done with monochrome mask and SetBkColor() function, I am really confused how is BkColor related to these bitmaps... And in the other one, SetTextColor() is used, for removing the background... How are these DC attributes (bkColor and textColor) related? Thanks


Solution

  • You are wrong BitBlt never uses text for background color. BitBlt raster operations use a pattern (that's the current selected brush), the source and destination bitmap.

    The dwRop code defines a calculation between this 3 data sources.

    You find a good explanation how this rop codes work in the book of Charles Petzold. Here is a corresponding chapter of the book. Read the part "The Raster Operations".