MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / ShowSplash

Function ShowSplash

ogsr_engine/xr_3da/splash.cpp:63–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61static HWND logoOwnerWindow = nullptr;
62
63void ShowSplash(HINSTANCE hInstance)
64{
65 WNDCLASS wc = {0};
66 wc.lpfnWndProc = DefWindowProc;
67 wc.hInstance = hInstance;
68 wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
69 wc.lpszClassName = c_szSplashClass;
70 RegisterClass(&wc);
71
72 // image
73 CImage img; // объект изображения
74
75 CHAR path[MAX_PATH];
76
77 GetModuleFileName(nullptr, path, MAX_PATH);
78
79 std::string splash_path{path};
80 splash_path = splash_path.erase(splash_path.find_last_of('\\'), splash_path.size() - 1);
81 splash_path += "\\splash.png";
82
83 HRESULT hr = img.Load(splash_path.c_str()); // загрузка сплеша
84
85 if (FAILED(hr) || img.IsNull()) // если картинки нет на диске, то грузим из ресурсов
86 {
87 img.Destroy();
88 if (IStream* pStream = CreateStreamOnResource(MAKEINTRESOURCE(IDB_PNG1), TEXT("PNG")))
89 {
90 img.Load(pStream);
91 pStream->Release();
92 }
93 }
94
95 // фиксируем ширину картинки
96 // фиксируем высоту картинки
97 const int splashWidth = img.GetWidth();
98 const int splashHeight = img.GetHeight();
99
100 const HWND hwndOwner = CreateWindow(c_szSplashClass, NULL, WS_POPUP, 0, 0, 0, 0, NULL, NULL, hInstance, NULL);
101 const HWND hWnd = CreateWindowEx(WS_EX_LAYERED, c_szSplashClass, nullptr, WS_POPUP, 0, 0, 0, 0, hwndOwner, nullptr, hInstance, nullptr);
102
103 if (!hWnd)
104 return;
105
106 const HDC hdcScreen = GetDC(nullptr);
107 const HDC hDC = CreateCompatibleDC(hdcScreen);
108
109 HBITMAP hBmp = CreateCompatibleBitmap(hdcScreen, splashWidth, splashHeight);
110 const HBITMAP hbmpOld = (HBITMAP)SelectObject(hDC, hBmp);
111
112 // рисуем картиночку
113 for (int i = 0; i < img.GetWidth(); i++)
114 {
115 for (int j = 0; j < img.GetHeight(); j++)
116 {
117 BYTE* ptr = (BYTE*)img.GetPixelAddress(i, j);
118 ptr[0] = ((ptr[0] * ptr[3]) + 127) / 255;
119 ptr[1] = ((ptr[1] * ptr[3]) + 127) / 255;
120 ptr[2] = ((ptr[2] * ptr[3]) + 127) / 255;

Callers 1

WinMain_implFunction · 0.85

Calls 10

CreateStreamOnResourceFunction · 0.85
SetWindowPosFunction · 0.85
GetWidthMethod · 0.80
GetHeightMethod · 0.80
eraseMethod · 0.45
sizeMethod · 0.45
LoadMethod · 0.45
c_strMethod · 0.45
DestroyMethod · 0.45
ReleaseMethod · 0.45

Tested by

no test coverage detected