C++ Drawing Mode 绘图方式

来源:互联网 发布:php 招聘信息系统 编辑:程序博客网 时间:2024/05/17 02:01

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实现了一下



原创粉丝点击