diff --git a/data/splash.bmp b/data/splash.bmp deleted file mode 100644 index 575919b..0000000 Binary files a/data/splash.bmp and /dev/null differ diff --git a/data/splash.jpg b/data/splash.jpg new file mode 100644 index 0000000..a0c6ac6 Binary files /dev/null and b/data/splash.jpg differ diff --git a/src/main.cpp b/src/main.cpp index ab3b107..6c9d2bb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -595,6 +595,25 @@ void win32_save_window_state() p.rcNormalPosition.top, p.rcNormalPosition.right, p.rcNormalPosition.bottom })); } +HBITMAP load_image(const std::string& path) +{ + int w, h, c; + stbi_set_flip_vertically_on_load(true); + auto rgb = std::unique_ptr(stbi_load(path.c_str(), &w, &h, &c, 3)); + if (!rgb) + return NULL; + BITMAPINFOHEADER bmih; + memset(&bmih, 0, sizeof(BITMAPINFOHEADER)); + bmih.biWidth = w; + bmih.biHeight = h; + bmih.biBitCount = 24; + bmih.biCompression = BI_RGB; + bmih.biSize = sizeof(BITMAPINFOHEADER); + bmih.biPlanes = 1; + BITMAPINFO* bmi = (BITMAPINFO*)&bmih; + return CreateDIBitmap(GetDC(NULL), &bmih, CBM_INIT, rgb.get(), bmi, DIB_RGB_COLORS); +} + LRESULT CALLBACK splash_proc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { switch (Msg) @@ -603,8 +622,9 @@ LRESULT CALLBACK splash_proc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lPara { static char base_path[MAX_PATH]; GetCurrentDirectoryA(MAX_PATH, base_path); - std::string path = std::string(base_path) + "\\data\\splash.bmp"; - auto hbitmap = (HBITMAP)LoadImageA(NULL, path.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); + std::string path = std::string(base_path) + "\\data\\splash.jpg"; + //auto hbitmap = (HBITMAP)LoadImageA(NULL, path.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); + auto hbitmap = load_image(path); SendMessage(GetDlgItem(hWndDlg, IDC_STATIC_IMAGE), STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbitmap); SetDlgItemText(hWndDlg, IDC_STATIC_VERSION, g_version_number_w);