improve splash
This commit is contained in:
BIN
data/splash.jpg
BIN
data/splash.jpg
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 51 KiB |
34
src/main.cpp
34
src/main.cpp
@@ -595,23 +595,18 @@ void win32_save_window_state()
|
||||
p.rcNormalPosition.top, p.rcNormalPosition.right, p.rcNormalPosition.bottom }));
|
||||
}
|
||||
|
||||
HBITMAP load_image(const std::string& path)
|
||||
HBITMAP image_to_hbitmap(const Image& img)
|
||||
{
|
||||
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.biWidth = img.width;
|
||||
bmih.biHeight = img.height;
|
||||
bmih.biBitCount = 32;
|
||||
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);
|
||||
return CreateDIBitmap(GetDC(NULL), &bmih, CBM_INIT, img.data(), bmi, DIB_RGB_COLORS);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK splash_proc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
|
||||
@@ -620,20 +615,23 @@ LRESULT CALLBACK splash_proc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lPara
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
{
|
||||
static char base_path[MAX_PATH];
|
||||
GetCurrentDirectoryA(MAX_PATH, base_path);
|
||||
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);
|
||||
|
||||
auto monitor = MonitorFromWindow(0, MONITOR_DEFAULTTOPRIMARY);
|
||||
auto x = unsigned{};
|
||||
auto y = unsigned{};
|
||||
GetDpiForMonitor(monitor, MDT_EFFECTIVE_DPI, &x, &y);
|
||||
float z = (float)x / 96.f;
|
||||
|
||||
static char base_path[MAX_PATH];
|
||||
GetCurrentDirectoryA(MAX_PATH, base_path);
|
||||
std::string path = std::string(base_path) + "\\data\\splash.jpg";
|
||||
//auto hbitmap = (HBITMAP)LoadImageA(NULL, path.c_str(), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
|
||||
Image img;
|
||||
img.load_file(path);
|
||||
img.flip();
|
||||
auto hbitmap = image_to_hbitmap(img.resize(512 * z, 200 * z));
|
||||
SendMessage(GetDlgItem(hWndDlg, IDC_STATIC_IMAGE), STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hbitmap);
|
||||
SetDlgItemText(hWndDlg, IDC_STATIC_VERSION, g_version_number_w);
|
||||
|
||||
RECT r;
|
||||
GetClientRect(hWndDlg, &r);
|
||||
MoveWindow(GetDlgItem(hWndDlg, IDC_STATIC_IMAGE), 0, 0, 512 * z, 200 * z, TRUE);
|
||||
|
||||
Reference in New Issue
Block a user