Combining two bitmaps together?

Apr 15, 2015 at 8:41pm
Hello!

I've got two images that I'd like to combine during runtime:
https://drive.google.com/file/d/0B4jJofEOOjG4NEJaS2Y5ampsaWc/view?usp=sharing
https://drive.google.com/file/d/0B4jJofEOOjG4ZFZxY0dMd0R3eDA/view?usp=sharing
https://drive.google.com/file/d/0B4jJofEOOjG4RFhkSTRWa1UzOU0/view?usp=sharing

Active.bmp and HighPerformance.bmp are bitmaps I'd like to combine and example.bmp is an example of how I'd like it to look. Do you know how to combine them during runtime? I use just win32.
Apr 16, 2015 at 12:10am
Use TransparentBlt() to draw active.bmp on top of the other. Or use the Rectangle() function instead of active.bmp.
Apr 16, 2015 at 6:37pm
Thanks ahcfan, TransparentBlt() worked:
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);
Topic archived. No new replies allowed.