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.

  • 相关阅读:
    Sort
    RAID
    LeetCode总结 -- 一维动态规划篇
    Count and Say
    Dynamic Programming Introduction
    Mongodb与Redis应用指标对比
    精通有状态vs无状态(Stateful vs Stateless)—Immutable模式之姐妹篇
    Windows 安装 pytorch3d
    GitHub 图片无法显示 或 gist 无法访问
    LaTeX符号表,数学公式速查必备
  • 原文地址:https://www.cnblogs.com/hgy413/p/3693632.html
Copyright © 2011-2022 走看看