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年8月4日
    3
  • java fgc_记一次频繁FGC的简单排查

    java fgc_记一次频繁FGC的简单排查简书占小狼转载请注明原创出处,谢谢!如果读完觉得有收获的话,欢迎点赞加关注周末愉快,今天有时间记录一下上周遇到的一个问题,学习的脚步不能放慢,也不敢放慢。存在问题在线上环境进行服务压测,压测完成后,cpu使用率居高不下,很是费解,按理说已经没有压测请求了,这时消耗cpu资源的只有GC线程了,可以通过jstat命令查看一下JVM的GC情况,然后就碰到了诡异的GC问题。jstat命令jstat[…

    2022年6月19日
    24
  • webstorm 2021激活码【2021.8最新】

    (webstorm 2021激活码)最近有小伙伴私信我,问我这边有没有免费的intellijIdea的激活码,然后我将全栈君台教程分享给他了。激活成功之后他一直表示感谢,哈哈~IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html…

    2022年3月26日
    40
  • androidrepublic_android develop

    androidrepublic_android developPreferenceFragment用来显示首选项的设置,效果图如下:主布局文件:<RelativeLayoutxmlns:android=”http://schemas.android.com/apk/res/android”xmlns:tools=”http://schemas.android.com/tools”android:…

    2022年9月6日
    2
  • 存储过程调试

    存储过程调试

    2021年12月6日
    106
  • python监控网页变化教程_Python实时监控网站浏览记录实现过程详解

    python监控网页变化教程_Python实时监控网站浏览记录实现过程详解需求:(1)获取你对象chrome前一天的浏览记录中的所有网址(url)和访问时间,并存在一个txt文件中(2)将这个txt文件发送给指定的邮箱地址(你的邮箱)(3)建立例行任务,每天定时自动完成这些操作,你就可以通过邮件查看你对象每天看啥了准备macOSSierraPython3.6Chrome发送邮件的qq邮箱地址qq邮箱授权码SMTP服务器地址:smtp.qq.com接受邮件的邮箱地…

    2022年7月16日
    16

发表回复

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

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