使用winapi在同一窗口上显示2个图像

时间:2014-11-28 16:47:33

标签: c++ winapi bitmap

我想使用bitblrstretchblt等Winapi调用在同一窗口中显示2张图片。我怎样才能做到这一点?我正在使用以下代码:

hdc = BeginPaint(hWnd, &ps);
bmpExercising1 = LoadBitmap(GetModuleHandle(NULL),IDB_FILE1);
bmpExercising2 = LoadBitmap(GetModuleHandle(NULL),IDB_FILE2);
// Create a memory device compatible with the above DC variable
MemDCExercising1 = CreateCompatibleDC(hdc);
MemDCExercising2 = CreateCompatibleDC(hdc);
// Select the new bitmap
SelectObject(MemDCExercising1, bmpExercising1);
SelectObject(MemDCExercising1, bmpExercising1);

// suppose the size of window is 80*80 then
StretchBlt(hdc, 0, 0, 40, 40, MemDCExercising1, 0, 0,bmpExercising1.width,bmpExercising1,height, SRCCOPY);
StretchBlt(hdc, 40, 40, 80, 80, MemDCExercising2, 0, 0,bmpExercising2.width,bmpExercising2,height, SRCCOPY);

EndPaint(hWnd, &ps);

0 个答案:

没有答案