|
|
发表于 2015-9-10 17:03:14
|
显示全部楼层
广东省深圳市
临时给你写了个C++版的,看看是不是你要的效果
关键代码:
完整代码:
- #include <windows.h>
- #include <gdiplus.h>
- using namespace Gdiplus;
- #pragma comment(lib,"gdiplus.lib")
- #define WIN_TITLE L"HH"
- void OnPaint(HDC hdc)
- {
- Graphics graphics(hdc);
- Image image(L"C:\\Users\\Administrator\\Pictures\\qq.jpg");
- Image imageBack(L"C:\\Users\\Administrator\\Pictures\\1V4o5xqtgr_src.jpg");
- graphics.DrawImage(&imageBack, 0, 0);
- Rect rect(50, 50, 100, 100);
- GraphicsPath circlepath;
- circlepath.AddEllipse(rect);
- graphics.SetClip(&circlepath);
- graphics.DrawImage(&image,rect);
- Pen pen(Color(0, 0, 255));
- graphics.DrawPath(&pen, &circlepath);
- graphics.ResetClip();
- graphics.DrawImage(&image, 100, 100);
- }
- LRESULT WINAPI WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
- {
- PAINTSTRUCT ps;
- HDC hdc;
- switch (msg)
- {
- case WM_PAINT:
- hdc = BeginPaint(hwnd, &ps);
- OnPaint(hdc);
- EndPaint(hwnd, &ps);
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- }
- return DefWindowProc(hwnd, msg, wparam, lparam);
- }
- int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd)
- {
- ULONG_PTR token;
- GdiplusStartupInput input;
- WNDCLASS wc;
- GdiplusStartup(&token, &input, NULL);
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hInstance = hInstance;
- wc.lpfnWndProc = WndProc;
- wc.lpszClassName = WIN_TITLE;
- wc.lpszMenuName = NULL;
- wc.style = CS_VREDRAW | CS_HREDRAW;
- RegisterClass(&wc);
- HWND hwnd = CreateWindow(WIN_TITLE, WIN_TITLE, WS_OVERLAPPEDWINDOW, 0, 0, 600, 400,NULL,NULL,hInstance,NULL);
- ShowWindow(hwnd, nShowCmd);
- UpdateWindow(hwnd);
- MSG msg;
- ZeroMemory(&msg, sizeof(msg));
- while (GetMessage(&msg,NULL,0,0))
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- GdiplusShutdown(token);
- return 0;
- }
复制代码
|
|