BitBlt参数详解[通俗易懂]

BitBlt参数详解[通俗易懂]对BitBlt()这个函数的最后一个参数的意义一直不是太了解,只会使用SRCCOPY,最近的一个项目使用到了这个函数,但是要求要背景透明的将源绘制到目标区域上,源是背景色和字,怎么只拷贝字而把背景色透明化呢??我的解决方法是,把源的背景色绘制为白色,字为黑色,然后在BitBlt的时候最后一个参数用SRCAND,果然可以达到我要的效果,这是为什么呢?呵呵趁此机会好好看看这个参数介绍吧~~开始之前,首先要明白,绘制其实就是在给每一个像素点涂颜色,每种颜色都是由红蓝黄三要素组合而成,因此通过RGB颜色值可以

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

对BitBlt()这个函数的最后一个参数的意义一直不是太了解,只会使用SRCCOPY ,最近的一个项目使用到了这个函数,但是要求要背景透明的将源绘制到目标区域上,源是背景色和字,怎么只拷贝字而把背景色透明化呢?? 
我的解决方法是,把源的背景色绘制为白色,字为黑色,然后在BitBlt的时候最后一个参数用SRCAND,果然可以达到我要的效果,这是为什么呢?呵呵 趁此机会好好看看这个参数介绍吧~~ 
开始之前,首先要明白,绘制其实就是在给每一个像素点涂颜色,每种颜色都是由红蓝黄三要素组合而成,因此通过RGB 颜色值可以指定出一种颜色,一个 RGB 颜色值由三个两位十六进制数字组成,分别代表各自的颜色强度。例如,颜色值 #FF0000(十六进制) 之所以被渲染为红色,是因为红色的值达到了最高值 FF (等于十进制的 255)。同时红色也可以通过RGB(255,0,0)来表示,也可以通过二进制的0X11111001来表示。
BOOL BitBlt(HDC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight,  
 HDC hdcSrc, int nXSrc, int nYSrc, DWORD dwRop ); 

Parameters

hdcDest

[in] Handle to the destination device context.
目标设备HDC

nXDest

[in] Specifies the logical x-coordinate of the upper-left corner of the destination rectangle.
目标区域的左顶点在目标画布上的X坐标

nYDest

[in] Specifies the logical y-coordinate of the upper-left corner of the destination rectangle.
目标区域的左顶点在目标画布上的Y坐标

nWidth

[in] Specifies the logical width of the source and destination rectangles.
BitBlt操作区域的宽度

nHeight

[in] Specifies the logical height of the source and the destination rectangles.
BitBlt操作区域高度

hdcSrc

[in] Handle to the source device context.
源设备的HDC

nXSrc

[in] Specifies the logical x-coordinate of the upper-left corner of the source rectangle.
源区域左顶点在源画布上的X坐标

nYSrc

[in] Specifies the logical y-coordinate of the upper-left corner of the source rectangle.
源区域左顶点在源画布上的Y坐标

dwRop

[in] Specifies a raster-operation code.
光栅操作代码(关键参数)

These codes define how the color data for the source rectangle is to be combined with the color data for the destination rectangle to achieve the final color.

The following list shows some common raster operation codes.

Value Description
BLACKNESS Fills the destination rectangle using the color associated with index 0 in the physical palette.

This color is black for the default physical palette.

使用物理调色板的0索引颜色填充目标区域

(物理调色板的默认0索引颜色是黑色

DSTINVERT

Inverts the destination rectangle.

将目标区域的各像素点颜色值进行取反操作

MERGECOPY

Merges the colors of the source rectangle with the specified pattern by using the Boolean AND operator.

将源区域与指定的笔刷进行合并,即进行“AND()”

MERGEPAINT

Merges the colors of the inverted source rectangle with the colors of the destination rectangle by using the Boolean OR operator.

将源区域取反后与目标区域进行“ (OR)”操作

NOTSRCCOPY

Copies the inverted source rectangle to the destination.

将源区域色值取反后拷贝到目标区域

NOTSRCERASE

Combines the colors of the source and destination rectangles by using the Boolean OR operator and then inverts the resultant color.

将源区域与目标区域按照“(OR)”操作进行混合,然后将结果颜色进行取反操作

PATCOPY

Copies the specified pattern into the destination bitmap.

将指定的笔刷拷贝到目标位图上

PATINVERT

Combines the colors of the specified pattern with the colors of the destination rectangle by using the Boolean XOR operator.

通过“异或(XOR)”操作,将指定的笔刷与目标区域的颜色进行混合

PATPAINT Combines the colors of the pattern with the colors of the inverted source rectangle by using the Boolean OR operator.

The result of this operation is combined with the colors of the destination rectangle by using the Boolean OR operator.

SRCAND

Combines the colors of the source and destination rectangles by using the Boolean AND operator.

通过“按位与(AND)”操作混合源和目标区域。

SRCCOPY

Copies the source rectangle directly to the destination rectangle.

直接将源拷贝到目标区域

SRCERASE

Combines the inverted colors of the destination rectangle with the colors of the source rectangle by using the Boolean AND operator.

将目标区域颜色进行取反之后通过“按位与(AND)”操作与源进行混合

SRCINVERT

Combines the colors of the source and destination rectangles by using the Boolean XOR operator.

通过“异或(XOR)”操作混合源和目标区域

SRCPAINT

Combines the colors of the source and destination rectangles by using the Boolean OR operator.

通过“按位(OR)”操作混合源和目标区域

WHITENESS Fills the destination rectangle using the color associated with index 1 in the physical palette.

This color is white for the default physical palette.

使用物理调色板的1索引颜色填充目标区域

(物理调色板的默认1索引颜色是白色

For the complete list of raster operations codes, see Ternary Raster Operations.

Return Values

Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.

 

通过上述介绍,想必大家知道为什么了吧,我的背景是白色,字是黑色,在进行SRCAND操作的时候,白色是#ffffff 所以进行bitblt之后的颜色以目标区域的颜色为本,而因为字是黑色#000000,在进行与操作之后目标区的相应部分也成了黑色~~!因此看前来像是,将源以背景透明的方式拷贝到了目标上~~!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/180513.html原文链接:https://javaforall.net

(0)
上一篇 2022年10月18日 下午8:37
下一篇 2022年10月18日 下午8:37


相关推荐

  • java代码走查_java代码开发完成后,代码走查规范

    java代码走查_java代码开发完成后,代码走查规范代码走查注意事项 1 不变的值 尽量写个常量类 2 尽量使用 if else 不要一直 if 去判断 3 减少循环调用方法查询数据库 4 dao 层尽量不要用逻辑 尽量在 service 里写业务逻辑 5 金额使用 Bigdecimal 类型的 0 00 这种格式靠右显示 6 iframe 的弹框 要放到 js 里 可以缓存 放到 jsp 里每次都需要加载 7 ajax 对应 success 对应一个 error 异常 尽量用 error 网络

    2026年3月18日
    3
  • Python安装失败_python第三方库安装失败

    Python安装失败_python第三方库安装失败详细内容相信很多刚开始入门Python的菜鸟们在安装python第三方库的时候,多多少少都会遇到一些安装失败的问题。下面,我将结合自身经验,分享一下在windows操作系统上此类问题的解决办法。一、清楚自己所安装的python版本(2.7或3.6,andmore);(推荐学习:Python视频教程)二、检查是否安装了pip,pip版本是否可以使用;三、网络是否正常;如果确认上面都没有问题的话,就…

    2022年10月2日
    8
  • 用IDEA一年了,终于敢说自己会用了(IDEA配置和使用)[通俗易懂]

    作为Java老兵,我也是用了很多年的eclipse,为了与时俱进,于是切换到了IDEA。刚开始的时候感觉很不适应,感觉这玩意儿不如eclipse好用,影响工作效率,于是又换回eclipse。但是很多

    2022年2月16日
    50
  • windows密码获取 — LC5暴力激活成功教程Hash密码「建议收藏」

    windows密码获取 — LC5暴力激活成功教程Hash密码「建议收藏」​错,可以改,那,错过呢。。。—-网易云热评一、首先用QuarksPwDump导出hash值并存储到1.txtquarkspwdump–dump-hash-local–output1.txt二、下载并安装LC5并注册1、下载地址:回复2、双击lc5setup一路下一步,3、将hashgen和lc5替换了原文件4、双击lc5,并打开注册机,点击administrator三、使用方法1、点击会话,导入1.txt…

    2022年7月24日
    27
  • Java 通过正则表达式替换字符串

    Java 通过正则表达式替换字符串简介java中提供了两个类来支持正则表达式的操作,分别是java.util.regex下的Pattern类和Matcher类依据Pattern对象做为匹配模式对字符串展开匹配检查,然后Matcher实例在给定的Pattern实例的模式控制下进行字符串的匹配,在实际的开发中,为了方便我们很少直接使用Pattern类或Matcher类,而是使用String类下的方法进行替换。…

    2022年5月16日
    46
  • Ubuntu安装dos2unix命令

    Ubuntu安装dos2unix命令Ubuntu系统打开Windows下生成的文本文件,会在每行的末尾出现’^M’原因就是Windows和Linux的回车符是不同的在Windows下回车符是\r\n回车换行在Linux下回车符是\n最简单、最常用的解决方法是使用dos2unix命令转换:dos2unixfilenameUbuntu下dos2unix和unix2dos命令在tofrodos包中安装:apt-g

    2022年5月31日
    44

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号