この画像を、
平行四辺形をターゲットにして転送します。
画像が斜めになります。
PlgBlt関数で行えます。
〇プログラム例
#include <windows.h>
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
POINT pt;
LPSTR str = TEXT("こんにちは、日本");
static HDC hMemDC;
static HBITMAP hForeBmp;
static HFONT hFont[2];
LPSTR FORE_BitMapFile = TEXT("カップ.bmp");
static HINSTANCE hInstance;
static POINT point[3] = { {50,50},{350,0},{0,300} };
static BITMAP bmpFore;
static BLENDFUNCTION blendFunc = { AC_SRC_OVER,0,200,0 };
switch (uMsg)
{
case WM_DESTROY:
DeleteDC(hMemDC);
DeleteObject(hForeBmp);
DeleteObject(hFont[0]);
PostQuitMessage(0);
return 0;
case WM_CREATE:
hFont[0] = CreateFont(
40, 0, 0, 0,
FW_NORMAL, FALSE, FALSE, FALSE,
SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
VARIABLE_PITCH | FF_DONTCARE, L"メイリオ"
);
ShowWindow(hWnd, SW_SHOW);
hInstance = (HINSTANCE)GetWindowLong(hWnd, GWLP_HINSTANCE);
hdc = GetDC(hWnd);
hMemDC = CreateCompatibleDC(hdc);
hForeBmp = LoadImage(hInstance, FORE_BitMapFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
GetObject(hForeBmp, sizeof(BITMAP), &bmpFore);
ReleaseDC(hWnd, hdc);
return 0;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
SelectObject(hMemDC, hForeBmp);
//転送
PlgBlt(hdc, point, hMemDC, 0, 0,
bmpFore.bmWidth, bmpFore.bmHeight, NULL, 0, 0);
SelectObject(hdc, hFont[0]);
SetTextColor(hdc, RGB(0, 0xFF, 0));
TextOut(hdc, 0, 0, str, lstrlen(str));
EndPaint(hWnd, &ps);
return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
int APIENTRY wWinMain(
_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR ipCmdLine,
_In_ int nCmdShow
) {
WNDCLASSEXW wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = NULL;
wcex.hCursor = NULL;
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = NULL;
wcex.lpszClassName = TEXT("TestWindow");
wcex.hIconSm = NULL;
RegisterClassExW(&wcex);
HWND hWnd = CreateWindowEx(0UL, TEXT("TestWindow"), TEXT("日本"), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, 400, 400, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
DispatchMessage(&msg);
}
return (int)msg.wParam;
}