use jpg splash

This commit is contained in:
2019-05-20 21:09:38 +02:00
parent e5a3d803c9
commit 7c09a79eb6
3 changed files with 22 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 400 KiB

BIN
data/splash.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -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<uint8_t[]>(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);