在使用了SetWorkingImage之后再使用AlphaBlend函数就失效了
EasyX版本 : 20210730
Visual Studio版本 : 2019
做过的常识:
- 提前保存窗口HDC, 不奏效
下面是问题源码 (问题源码已经简化, 请不要讨论意义,必须使用AlphaBlend函数贴图, 具体项目保密)
#include <graphics.h>
#include <conio.h>
#pragma comment(lib, "MSIMG32.LIB")
void QPutimage(int x, int y, IMAGE* image, 
			int transparency = 255, IMAGE* target = NULL)
{
	HDC target_dc = GetImageHDC(target);
	HDC image_dc  = GetImageHDC(image);
	int width  = image->getwidth();
	int height = image->getheight();
	BLENDFUNCTION blend_function = { AC_SRC_OVER, 0, static_cast<BYTE>(transparency), AC_SRC_ALPHA };
	AlphaBlend(target_dc, x, y, width, height, 
				image_dc, 0, 0, width, height, 
				blend_function);
}
int main()
{
	initgraph(640, 480);
	IMAGE text_image(120, 120);
	
	SetWorkingImage(&text_image);
	outtextxy(0, 0, L"Hello World");
	SetWorkingImage(NULL);
	
	QPutimage(0, 0, &text_image);
	_getch();
    return 0;
}




