1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
// load 2 bitmaps - mask and background, create variables for default bmps from dcs
HBITMAP mask = LoadBitmap(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDB_ACTIVE)),
result = LoadBitmap(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDB_HIGH)), old1, old2;
// create dcs
HDC maskDc = CreateCompatibleDC(nullptr), res = CreateCompatibleDC(nullptr);
// remember old bmps from dcs
old1 = (HBITMAP) SelectObject(maskDc, mask);
old2 = (HBITMAP) SelectObject(res, result);
// combine bmps
TransparentBlt(res, 0, 0, 64, 64, maskDc, 0, 0, 64, 64, RGB(255, 255, 255));
// return default bmps, get our bmp back
SelectObject(maskDc, old1);
result = (HBITMAP) SelectObject(res, old2);
// clean up dcs
DeleteDC(maskDc);
DeleteDC(res);
|