TransparentBlt实现

参考:http://www.vckbase.com/document/viewdoc/?id=532

         http://www.mvps.org/user32/gditutorial.html

         以及MSDN2008中StrechBltSetBkColorSetTextColor 的Remarks部分。

         Updated@2010.12.25: Feng Yuan的GDI编程书的第10章Using DDBs的DDB Color Conversion

                                              小节有详细的介绍。。

 

这里我贴一下自己觉得从上面资料中找出的最重要的一些原理:

For a monochrome bitmap, the black area is really 0 bits and the white area is really 1 bits.

If StretchBlt must convert a monochrome bitmap to a color bitmap, it sets white
bits (1) to the background color and black bits (0) to the foreground color. To
convert a color bitmap to a monochrome bitmap, it sets pixels that match the
background color to white (1) and sets all other pixels to black (0). The
foreground and background colors of the device context with color are used.

Raster operations (SRCPAINT, SRCCOPY, etc) are performed only after any mapping
has taken place. They are performed bytewise on the image bytes. this is the most
efficient means of operation, but it means that logical raster operations performed
on 256 color displays will tend to have unexpected results, as any palettes are
totally ignored by this process. The default twenty system colors will behave in an
expected way, as the system palette has been arranged specially so the mappings
work. Instead of simply using the 1st twenty colors, the system palette uses the
first ten, and last ten colors, so when a NOT is performed on black (color index 0)
the result of the NOT operation (color index 255) is the expected white.

 

啥不说了,贴代码(里面有详细的注释):

 

附图一张(可以测试下,不让上传BMP图,转成gif了):

可以用上面的理论改写《Windows程序设计》第五版14章的BitMask例子,可以不用Rop 0x220326。。。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值