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. This color is black for the default physical palette. 使用物理調色板的0索引顏色填充目標區域 (物理調色板的默認0索引顏色是黑色) Inverts the destination rectangle. 將目標區域的各像素點顏色值進行取反操作 Merges the colors of the source rectangle with the specified pattern by using the Boolean AND operator. 將源區域與指定的筆刷進行合併,即進行“AND(與)” Merges the colors of the inverted source rectangle with the colors of the destination rectangle by using the Boolean OR operator. 將源區域取反後與目標區域進行“或 (OR)”操作 Copies the inverted source rectangle to the destination. 將源區域色值取反後拷貝到目標區域 Combines the colors of the source and destination rectangles by using the Boolean OR operator and then inverts the resultant color. 將源區域與目標區域按照“或(OR)”操作進行混合,然後將結果顏色進行取反操作 Copies the specified pattern into the destination bitmap. 將指定的筆刷拷貝到目標位圖上 Combines the colors of the specified pattern with the colors of the destination rectangle by using the Boolean XOR operator. 通過“異或(XOR)”操作,將指定的筆刷與目標區域的顏色進行混合 The result of this operation is combined with the colors of the destination rectangle by using the Boolean OR operator. Combines the colors of the source and destination rectangles by using the Boolean AND operator. 通過“按位與(AND)”操作混合源和目標區域。 Copies the source rectangle directly to the destination rectangle. 直接將源拷貝到目標區域 Combines the inverted colors of the destination rectangle with the colors of the source rectangle by using the Boolean AND operator. 將目標區域顏色進行取反之後通過“按位與(AND)”操作與源進行混合 Combines the colors of the source and destination rectangles by using the Boolean XOR operator. 通過“異或(XOR)”操作混合源和目標區域 Combines the colors of the source and destination rectangles by using the Boolean OR operator. 通過“按位或(OR)”操作混合源和目標區域 This color is white for the default physical palette. 使用物理調色板的1索引顏色填充目標區域 (物理調色板的默認1索引顏色是白色) For the complete list of raster operations codes, see Ternary Raster Operations. Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError. 通 過上述介紹,想必大家知道爲什麼了吧,我的背景是白色,字是黑色,在進行SRCAND操作的時候,白色是#ffffff 所以進行bitblt之後的顏色以目標區域的顏色爲本,而因爲字是黑色#000000,在進行與操作之後目標區的相應部分也成了黑色~~!因此看前來像 是,將源以背景透明的方式拷貝到了目標上~~!對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
Value
Description
BLACKNESS
Fills the destination rectangle using the color associated with index 0 in the physical palette.
DSTINVERT
MERGECOPY
MERGEPAINT
NOTSRCCOPY
NOTSRCERASE
PATCOPY
PATINVERT
PATPAINT
Combines the colors of the pattern with the colors of the inverted source rectangle by using the Boolean OR operator.
SRCAND
SRCCOPY
SRCERASE
SRCINVERT
SRCPAINT
WHITENESS
Fills the destination rectangle using the color associated with index 1 in the physical palette.
Return Values
BitBlt詳解
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.