SetROP2设置绘图模式

一、函数原型:

int SetROP2( HDC hdc, int fnDrawMode);

二、返回值:

函数调用成功后返回调用前的模式,调用失败则返回零。

三、参数:​

1、R2_BLACK//Pixel is always black. 所有绘制出来的像素为黑色

2、R2_WHITE//Pixel is always white. 所有绘制出来的像素为白色

3、R2_NOP//Pixel remains unchanged. 任何绘制将不改变当前的状态

4、R2_NOT//Pixel is the inverse of the screen color. 当前绘制的像素值设为屏幕像素值的反

5、R2_COPYPEN//Pixel is the pen color. 使用当前的画笔的颜色

6、R2_NOTCOPYPEN//Pixel is the inverse of the pen color. 当前画笔的反色

//下面是当前画笔的颜色和屏幕色的组合运算得到的绘图模式。

7、R2_MERGEPENNOT//Pixel is a combination of the pen color and the inverse of the screen color (final pixel = (NOT screen pixel) OR pen). R2_COPYPEN和R2_NOT的并集(注:merge:混合)。

8、R2_MASKPENNOT//Pixel is a combination of the colors common to both the pen and the inverse of the screen (final pixel = (NOT screen pixel) AND pen). R2_COPYPEN和R2_NOT的交集

9、R2_MERGENOTPEN//Pixel is a combination of the screen color and the inverse of the pen color (final pixel = (NOT pen) OR screen pixel). R2_NOTCOPYPEN和屏幕像素值的并集

10、R2_MASKNOTPEN//Pixel is a combination of the colors common to both the screen and the inverse of the pen (final pixel = (NOT pen) AND screen pixel).R2_NOTCOPYPEN和屏幕像素值的交集

11、R2_MERGEPEN//Pixel is a combination of the pen color and the screen color (final pixel = pen OR screen pixel). R2_COPYPEN和屏幕像素值的并集

12、R2_NOTMERGEPEN//Pixel is the inverse of the R2_MERGEPEN color (final pixel = NOT(pen OR screen pixel)). R2_MERGEPEN的反色

13、R2_MASKPEN//Pixel is a combination of the colors common to both the pen and the screen (final pixel = pen AND screen pixel). R2_COPYPEN和屏幕像素值的交集

14、R2_NOTMASKPEN//Pixel is the inverse of the R2_MASKPEN color (final pixel = NOT(pen AND screen pixel)). R2_MASKPEN的反色

15、R2_XORPEN//Pixel is a combination of the colors that are in the pen or in the screen, but not in both (final pixel = pen XOR screen pixel). R2_COPYPEN和屏幕像素值的异或

16、R2_NOTXORPEN//Pixel is the inverse of the R2_XORPEN color (final pixel = NOT(pen XOR screen pixel)). R2_XORPEN的反色

​注:比较重要的两个:R2_NOT与R2_NOTXORPEN:

通过设置SetROP2( R2_NOT);或者SetROP2(R2_NOTXORPEN)
画两次,便可以插除图形。如果两次绘图间隔一段时间,会表现出闪烁效果。
网上找的是:
1.R2_NOT:当前绘制的像素值设为屏幕像素值的反,这样可以覆盖掉上次的绘图,(自动擦除上次绘制的图形)
2.R2_NOTXORPEN:对当前的画笔的颜色和屏幕像素值的异或进行取反

现假设屏幕初始像素值为A,画笔为B
就第1种情况分析:
画第一次时颜色为!A;
第二次画时屏幕像素由A变为!A,则第二次画的颜色!!A=A,即用背景色来填充,相当于清除了。
就第二种情况分析:
第一次画时颜色为!(B^A)
第二次画时屏幕像素由A变为C=!(B^A),则第二次画的颜色为!(B^C)=!(B^!B^A)=!(1^A)=!!A=A,同上

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小米的修行之路

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值