| | |
|
岱瀛
(deving)
| |
| | |
|
| | |
|
组别 | 经略使 |
级别 | 左将军 |
好贴 | 1 |
功绩 | 2293 |
帖子 | 1370 |
编号 | 55810 |
注册 | 2005-12-22 |
来自 | 人间 |
家族 | 慕容世家 |
| |
| | |
|
|
|
原帖由 JLQSheenero 于 2007-7-31 09:43 发表
我也在自己开发引擎,但是最后发现图像镂空处理的时候竟然把图像内部的黑色也镂
了。请问应怎样用Bitblt,才不会挖掉内部的黑色。(还是个初中生,弱弱……) 一般这种镂空都会牺牲掉一种颜色来处理的。比如你用纯黑色RGB(255,255,255)做底,你图片内部的黑,你用(255,255,254)之类的,肉眼是分辨不出来的,但是程序是能判断出来的,这样就可以达到你要的镂空效果了。
其实画镂空也不必要自己用Bitblt来做了,挺麻烦的。 Windows提供有下面这个函数可以用。
(传说win 2000以下的不太能用,2000以上的OS就无所谓了)
函数的信息如下:
TransparentBlt
The TransparentBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.
BOOL TransparentBlt(
HDC hdcDest,
int nXOriginDest,
int nYOriginDest,
int nWidthDest,
int hHeightDest,
HDC hdcSrc,
int nXOriginSrc,
int nYOriginSrc,
int nWidthSrc,
int nHeightSrc,
UINT crTransparent
);
Parameters
hdcDest
Handle to the destination device context.
nXOriginDest
Specifies the x-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nYOriginDest
Specifies the y-coordinate, in logical units, of the upper-left corner of the destination rectangle.
nWidthDest
Specifies the width, in logical units, of the destination rectangle.
hHeightDest
Handle to the height, in logical units, of the destination rectangle.
hdcSrc
Handle to the source device context.
nXOriginSrc
Specifies the x-coordinate, in logical units, of the source rectangle.
nYOriginSrc
Specifies the y-coordinate, in logical units, of the source rectangle.
nWidthSrc
Specifies the width, in logical units, of the source rectangle.
nHeightSrc
Specifies the height, in logical units, of the source rectangle.
crTransparent
The RGB color in the source bitmap to treat as transparent.
Return Values
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE.
Windows NT: To get extended error information, callGetLastError.
Remarks
The TransparentBlt function is supported for source bitmaps of 4 bits per pixel and 8 bits per pixel. Use AlphaBlend to specify 32-bit per pixel bitmaps with transparency.
If the source and destination rectangles are not the same size, the source bitmap is stretched to match the destination rectangle. When the SetStretchBltMode function is used, the iStretchMode modes of BLACKONWHITE and WHITEONBLACK are converted to COLORONCOLOR for the TransparentBlt function.
The destination device context specifies the transformation type for the destination coordinates. The source device context specifies the transformation type for the source coordinates.
TransparentBlt does not mirror a bitmap if either the width or height, of either the source or destination, is negative.
|
|
|