need help trying to get an image to display on the screen using gdiplus and windows.h
relevant code:
#pragma comment(lib, "comctl32.lib")
#pragma comment(lib, "gdiplus.lib")
//#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <windows.h>
#include <gdiplus.h>
#include <CommCtrl.h>
#include <Commdlg.h>
#include <string>
#include <fstream>
Image* g_Image = nullptr;
ULONG_PTR g_gdiplusToken{};
void LoadImageFile(HWND hwnd)
{
wchar_t szFile[MAX_PATH]{};
OPENFILENAMEW ofn{};
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.lpstrFile = szFile;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = L"Images\0*.png;*.jpg;*.bmp\0";
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (GetOpenFileNameW(&ofn))
{
delete g_Image;
g_Image = Image::FromFile(szFile, FALSE);
if (g_Image->GetLastStatus() != Ok)
{
delete g_Image;
g_Image = nullptr;
MessageBoxW(hwnd, L"Failed to load image", L"GDI+ Error", MB_ICONERROR);
return;
}
InvalidateRect(hwnd, nullptr, TRUE);
}
}