Settings | Sign in | Sign up

There are currently 3 posts.

【用法】AlphaBlend半透明函数的用法

Floor 1 巨大八爪鱼 7/7/16 23:12

BLENDFUNCTION bdf;
ZeroMemory(&bdf, sizeof(bdf));
bdf.SourceConstantAlpha = 150; // 指定不透明度(0为完全透明, 255为完全不透明)
SelectObject(hdcMem, hbmp); // 选入要复制的位图
AlphaBlend(hdc, 50, 50, bmp.bmWidth / 2, bmp.bmHeight / 2, hdcMem, 0, 0, bmp.bmWidth, bmp.bmHeight, bdf);


运行效果:

Floor 2 巨大八爪鱼 7/7/16 23:17

各参数的解释:
AlphaBlend(目标设备DC, 显示位置x坐标, 显示位置y坐标, 显示宽度, 显示高度, 含有图像的DC, 开始截取位置x坐标, 开始截取位置y坐标, 截取宽度, 截取高度, 半透明属性);

合理调整显示宽度和高度可以缩放图像,例如bmp.bmWidth / 2, bmp.bmHeight / 2就是缩小为原尺寸的50%。

函数执行时先进行原图像剪切,未剪切的部分不会显示出来。

Floor 3 巨大八爪鱼 7/7/16 23:18
如果bdf.SourceConstantAlpha为255的话,此函数就相当于StretchBlt。

Content converter:

Reply the post
Content:
User: You are currently anonymous.
Captcha:
Unclear? Try another one.