TransparentBlt函数调用来贴图透明显示没有效果怎么办?图片大小是LoadImage中的大小
程序代码:
//初始化 BOOL Game_Init(HWND hwnd) { g_hdc = GetDC(hwnd); g_hBackGround = (HBITMAP)LoadImage(NULL, L"bg.bmp", IMAGE_BITMAP, WINDOW_WIDTH, WINDOW_HEIGHT, LR_LOADFROMFILE); g_hSprite1 = (HBITMAP)LoadImage(NULL, L"character1.bmp", IMAGE_BITMAP, 535, 650, LR_LOADFROMFILE); g_hSprite2 = (HBITMAP)LoadImage(NULL, L"character2.bmp", IMAGE_BITMAP, 506, 650, LR_LOADFROMFILE); g_mdc = CreateCompatibleDC(g_hdc); Game_Paint(hwnd); ReleaseDC(hwnd, g_hdc); return TRUE; } //在函数中进行绘制操作 VOID Game_Paint(HWND hwnd) { SelectObject(g_mdc, g_hBackGround); BitBlt(g_hdc, 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, g_mdc, 0, 0, SRCCOPY); SelectObject(g_mdc, g_hSprite1); TransparentBlt(g_hdc, 0, WINDOW_HEIGHT - 650, 535, 650, g_mdc, 0, 0, 535, 650, RGB(0, 0, 0));//设置RGB(0, 0, 0)为透明色 SelectObject(g_mdc, g_hSprite2); TransparentBlt(g_hdc, 500, WINDOW_HEIGHT - 650, 506, 650, g_mdc, 0, 0, 506, 650, RGB(0, 0, 0)); } //资源清理函数 BOOL Game_CleanUp(HWND hwnd) { DeleteObject(g_hBackGround); DeleteObject(g_hSprite1); DeleteObject(g_hSprite2); DeleteDC(g_mdc); return TRUE; }