📄 ddbase.htm
字号:
style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2px"><font
color="#FFFFFF">int nXDest, //目标设备环境的矩形区域的左上角的x坐标</font></p>
<p
style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2px"><font
color="#FFFFFF">int nYDest, //目标设备环境的矩形区域的左上角的y坐标</font></p>
<p
style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2px"><font
color="#FFFFFF">int nWidth, //目标设备环境的矩形区域的宽度值</font></p>
<p
style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2px"><font
color="#FFFFFF">int nHeight, //目标设备环境的矩形区域的高度值</font></p>
<p
style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2px"><font
color="#FFFFFF">HDC hdcSrc, //源设备环境的句柄</font></p>
<p
style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2px"><font
color="#FFFFFF">int nXSrc, //源设备环境的矩形区域的左上角的x坐标</font></p>
<p
style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2px"><font
color="#FFFFFF">int nYSrc, //源设备环境的矩形区域的左上角的y坐标</font></p>
<p
style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2px"><font
color="#FFFFFF">DWORD dwRop //光栅操作符</font></p>
<p
style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2px"><font
color="#FFFFFF">);</font></p>
<p ALIGN="JUSTIFY"
style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2px"> </p>
</blockquote>
<blockquote>
<p ALIGN="JUSTIFY"><font FACE="宋体" SIZE="3">dwRop参数是光栅操作代码(Rop),它是指源位图与目标位图以及图案刷的颜色值进行布尔运算的方式,以下列出了常用的光栅操作符。</p>
</font>
</blockquote>
<font FACE="宋体" SIZE="3"><div align="center"><center>
<table BORDER="1" CELLSPACING="0" CELLPADDING="7" WIDTH="559" style="margin-left: 40"
height="562">
<tr>
<td WIDTH="105" VALIGN="MIDDLE" HEIGHT="16"><b><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">光栅操作代码</b></td>
<td WIDTH="418" VALIGN="MIDDLE" HEIGHT="16"><b><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">含义</b></td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">BLACKNESS</td>
<td WIDTH="418" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">用黑色填充目标矩形区域。</td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">DSTINVERT </td>
<td WIDTH="418" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">将目标矩形图象进行反相。
</td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">MERGECOPY </td>
<td WIDTH="418" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">将源矩形图象与指定的图案刷(Pattern)进行布尔“与”运算。
</td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">MERGEPAINT </td>
<td WIDTH="418" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">将源矩形图形经过反相后,与目标矩形图象进行布尔“或”运算。</td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">NOTSRCCOPY </td>
<td WIDTH="418" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">将源矩形图象经过反相后,复制到目标矩形上。</td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="18"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">NOTSRCERASE </td>
<td WIDTH="418" VALIGN="TOP" height="18"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">先将源矩形图象与目标矩形图象进行布尔“或”运算,然后再将所得图象进行反相。</td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">PATCOPY </td>
<td WIDTH="418" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">将指定的图案刷复制到目标矩形上。</td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">PATINVERT</td>
<td WIDTH="418" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">将指定的图案刷与目标矩形图象进行布尔“异或”运算。</td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="32"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">PATPAINT</td>
<td WIDTH="418" VALIGN="TOP" height="32"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">先将源矩形图象进行反相,与指定的图案刷进行布尔“或”运算,再与目标矩形图象进行布尔“或”运算。</td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">SRCAND </td>
<td WIDTH="418" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">将源矩形图象与目标矩形图象进行布尔“与”运算。</td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">SRCCOPY </td>
<td WIDTH="418" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">将源矩形图象直接复制到目标矩形上。</td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">SRCERASE </td>
<td WIDTH="418" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">将目标矩形图象进行反相,再与源矩形图象进行布尔“与”运算。</td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">SRCINVERT </td>
<td WIDTH="418" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">将源矩形图象与目标矩形图象进行布尔“异或”运算。</td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">SRCPAINT </td>
<td WIDTH="418" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">将源矩形图象与目标矩形图象进行布尔“或”运算。</td>
</tr>
<tr>
<td WIDTH="105" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">WHITENESS </td>
<td WIDTH="418" VALIGN="TOP" height="16"><p ALIGN="JUSTIFY"
style="margin-top: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0">用白色填充目标矩形区域。</td>
</tr>
</table>
</center></div>
<blockquote>
<p ALIGN="JUSTIFY">表中,提到了三种的基本布尔运算,分别是:反相(NOT)、与(AND)、或(OR)。还提到了异或(XOR),学过数理逻辑的人都知道,异或运算其实也是可以由前三种组合出来的。可以看出,所有的光栅操作代码都是由三种基本布尔运算组合而成。实际上,一共有256种光栅操作代码,但最常用的就是以上这15种。若想使用这15种以外的任何一种时,可以查阅VC的帮助,但在实际中,它们是极少被用到的。</p>
</blockquote>
<blockquote>
<p ALIGN="JUSTIFY">图案刷(英文是Pattern,
也可翻译成模式刷,直接的意思是布料上图案的花样)是Windows资源的一种,属于Brush,它其实是一个固定大小的位图(通常为8x8像素),用来平铺填充设备环境(DC)的某一区域。它的用法与普通的刷子是没有区别的,当把一个图案刷用SelectObject函数选定给某设备环境,再在该设备环境中进行填充操作,那么所填充的不是一个单纯的颜色(选用普通的刷子时的情况),而是连续平铺的图案。</p>
</blockquote>
<blockquote>
<p ALIGN="JUSTIFY">GDI的blit函数还有PatBlt和StretchBlt。它们与BitBlt大同小异,BitBlt具有Patblt的所有功能,StretchBlt除了具有BitBlt的一切功能外,它还可以将位图放大或缩小,实现缩放功能。</p>
</blockquote>
<blockquote>
<p ALIGN="JUSTIFY">DirectDraw最常用的blit函数是IDirectDrawSurface3::Blt,它的原型如下:</p>
</blockquote>
<blockquote>
<p style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2"><font
color="#FFFFFF">HRESULT IDirectDrawSurface3::Blt(</font></p>
<p style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2"><font
face="宋体" size="3" color="#FFFFFF">LPRECT lpDestRect, //目标矩形区</font></p>
<p style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2"><font
face="宋体" size="3" color="#FFFFFF">LPDIRECTDRAWSURFACE3 lpDDSrcSurface, //源页面</font></p>
<p style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2"><font
face="宋体" size="3" color="#FFFFFF">LPRECT lpSrcRect, //源矩形区</font></p>
<p style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2"><font
face="宋体" size="3" color="#FFFFFF">DWORD dwFlags, //标志符</font></p>
<p style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2"><font
face="宋体" size="3" color="#FFFFFF">LPDDBLTFX lpDDBltFx //光栅操作代码及特效</font></p>
<p style="background-color: rgb(0,0,128); margin-top: 0; margin-bottom: 0; padding-top: 2"><font
color="#FFFFFF">);</font></p>
</blockquote>
<blockquote>
<p ALIGN="JUSTIFY">DirectDraw中的Blt函数比GDI中的BitBlt函数虽然在形式上极为相似,但在内容上却有了质的飞跃。首先,从运行速度上来比较,IDirectDrawSurface3::Blt可以利用到一切可以利用的硬件加速特性,而且该操作在缺省情况下是异步执行的,这意味着程序不需要等待blit结束才返回,而是在给系统发出了blit的指令后,立即返回,然后系统在后台进行blit操作,这使程序的运行变得极为高效、快速;其次,它还支持带源和目标关键色以及z缓存和alpha
通道的blit操作,这使得用该blit函数来完成各种效果变得极更为容易。</p>
</blockquote>
<blockquote>
<p ALIGN="JUSTIFY">该函数的目标页面就是调用者本身,而且矩形区域用RECT结构表示。第四个参数dwFlays表示该blit操作的类型,最后一个参数lpDDBltFx是一个包含了光栅操作代码和其它特效的结构,其中的光栅操作代码成员与Win32的是兼容的。</p>
</blockquote>
<blockquote>
<p ALIGN="JUSTIFY">DirectDraw中的blit函数还有IDirectDrawSurface3::BltFast和IDirectDrawSurface3::
BltBatch。前者完成一次显存中的blit操作,在没有硬件加速的情况下,其速度可以较Blt快一些,后者完成一组blit操作。</p>
</blockquote>
<blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -