zoukankan      html  css  js  c++  java
  • HDC中的前景色与背景色

    HDC中的前景色与背景色

        

    在制作透明位图时,经常用到单色图(遮罩图,两色图)将他与目标位图进行"与""或"等操作就能得到想要的透明效果,在其中用到的最多的就是BitBlt这个函数,另外,在使用之前是要对目标位图进行前景和后景颜色的设置,为什么呢?请看MSDN的解说:

     

    单色图与彩色图之间的转换

      模拟透明的方法也包含基于windows的单色图向彩色图转换的机制,反之亦然。Windows概念中的文本颜色(前景色)和背景色被用来映射两种格式的转换。在blt操作中,当dest为彩色图,src为单色图时,在进行ROP(SRCAND,SRCAND,SRCINVERT,SRCPAINT等),操作之前,单色图src中的0(black)像素被转换成dest的前景色,1(white)像素被转化为dest的背景色。相反,从彩色图向单色图转换时,即dest为单色图,src为彩色图时,src彩色图中所有与其背景颜色相同的像素变成1,与其背景不同的变为0。

      Transparency simulation can also involve the Windows-based mechanism for converting monochrome bitmaps to color bitmaps and vice versa. The Windows-based notion of a text (foreground) color and a background color is used to map between the two formats. During a blt operation with a color destination, a monochrome source bitmap (and/or a brush when applicable) is converted to color on the fly before the actual ROP is carried out on the bits. The 0 (black) pixels in the monochrome bitmap are converted to the destination's text (foreground) color, and the 1 (white) pixels are converted to the background color. Conversely, Windows converts a color source into monochrome when the destination is monochrome. In this situation, all pixels in the color bitmap that are the same color as the background color become 1s, and all the other pixels are converted to 0s. Because all of the examples below use monochrome masks, it is critical for an application to properly set the foreground and background colors (using SetTextColor and SetBkColor) before performing the blt operations.

  • 相关阅读:
    python基础练习:
    py+selenium切换到新弹出窗口通用方法
    Python 异常处理
    验证码自动化认证部分,可能由于分辨率导致截图不正确
    基于Tesseract的OCR图像识别
    Spark相关知识
    Hive和数据库除了拥有类似的查询语言,再无类似之处;关系型数据库和非关系型数据库的优缺点
    sed替换^A(01),02,03等特殊字符
    Python操作adb命令脚本
    python从放弃到放弃
  • 原文地址:https://www.cnblogs.com/hgy413/p/3693632.html
Copyright © 2011-2022 走看看