Try to add this line to your code:
#pragma comment(lib, "gdi32")
Or add Gdi32.lib to Linker, Input, Additional Dependencies field of Project Properties (for all configurations).
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am developing a desktop application in WinUI3 that deals with bitmap images. I need the image data to be stored in the bitmap structure defined in wingdi.h for compatibility purposes.
Using the Win32API, I've written the following code:
void MainWindow::myButton_Click(IInspectable const&, RoutedEventArgs const&)
{
BITMAP bmp;
LPCWSTR path = L"C:\\test.bmp";
HBITMAP hbm = (HBITMAP)LoadImage(NULL, path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
GetObject(hbm, sizeof(BITMAP), &bmp);
}
However, I'm encountering the following error when building:
Error LNK2019 unresolved external symbol __imp_GetObjectW referenced in function "public: void __cdecl winrt::LoadBmpTest::implementation::MainWindow::myButton_Click(struct winrt::Windows::Foundation::IInspectable const &,struct winrt::Microsoft::UI::Xaml::RoutedEventArgs const &)" (?myButton_Click@MainWindow@implementation@LoadBmpTest@winrt@@QEAAXAEBUIInspectable@Foundation@Windows@4@AEBURoutedEventArgs@Xaml@UI@Microsoft@4@@Z) LoadBmpTest
there an issue with using GetObject in a WinUI3 environment? In any case, I'm interested in storing the image data in a bitmap structure. Are there alternative methods that I can try?
Try to add this line to your code:
#pragma comment(lib, "gdi32")
Or add Gdi32.lib to Linker, Input, Additional Dependencies field of Project Properties (for all configurations).