I am making bitmap(8bit depth DIB format) pasting operation from clipboard
to my app.
One of pasting mode I need is as follows,
only these positions whose color = 0 on destination bitmap will be changed
by source bitmap(here is clipboard).
That is to say, if color != 0, color will keep unchanged.
Can I do that by BitBlt(,,,,,,,,dwRop)?
If yes, how should I set dwRop parameter?
TIA
William
I don't believe BitBlt can do it directly.
What you could do is the following. Get the "destination" bitmap and the
"source" bitmap into memory device contexts (making whatever conversions are
necessary). Then use TransparentBlt to copy from the "destination" memory DC
to the "source" memory DC using black as the transparent color. The result
of this will be that the "source" memory DC has the "destination's"
non-black pixels and retains its own pixels where the "destination" is
black. This would seem to be the combination you are after.
For Windows version where TransparentBlt doesn't exist or leaks memory, you
can use the following workaround:
http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B79212
--
John Carson
If the source bitmap is only black and white, you can use a single
StretchDIBits call with the right ROP; otherwise you need to read the source
bitmap first.
Feng Yuan