C++ Drawing Mode 绘图方式

void CMainWindow::OnPaint()
{
	CPaintDC dc(this);
	CBrush brush(RGB(0,0,0));
	CRect rect;
	GetClientRect(&rect);
	dc.FillRect(&rect,&brush);
	dc.SetROP2(R2_NOT);
	dc.MoveTo(m_ptBegin);
	dc.LineTo(m_ptEnd);
}

SetROP2在Programming Windows with MFC中是这样解释的

When the GDI outputs pixels to a logical display surface, it doesn't simply output pixel colors. Rather, it combines the colors of the pixels that it's outputting with the colors of the pixels at the destination using a combination of Boolean operations.


让人很不解,然后翻开Programming Windows看到是这样的:

当Windows使用画笔来画线时,它实际上运行画笔像素与目标位置处原来像素之间的某种位布尔运算。像素间的位布尔运算叫做“位映像运算”,简称为“ROP”。由于画一条直线只涉及两种像素(画笔和目标),因此这种布尔运算又称为“二元位映像运算”,简记为“ROP2”。Windows定义了16种ROP2代码,表示Windows组合画笔像素和目标像素的方式。


这就比较清楚了

然后自己在MFC中用R2_NOT实现了一下



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值