1

I am trying to load a picture (.bmp or .jpg) with this code:

HDC hdc = GetDC(NULL);
Gdiplus::Bitmap* image = Gdiplus::Bitmap::FromFile(fileName, false);
if (image == NULL) {
    std::cout << "Picture not found" << std::endl;
    return false;
}

I always get "Picture not found". I 've tried the following:

TCHAR* fileName = L"background.bmp";
TCHAR* fileName = L"C:\\background.bmp";

The picture is on C: and in the project folder. Where should I save the image, so that it can be found? Or am I doing something essential wrong or am I missing something? I am using Visual Studio2013 and a Win32 console application (native C++). Thank you for your help

The Coder
  • 143
  • 8
  • `TCHAR* fileName = L"C:\\background.bmp";` means look at the root folder of c: – drescherjm Jan 19 '16 at 23:51
  • ***The picture is on C: and in the project folder. Where should I save the image, so that it can be found?*** The default folder is normally the same folder as the one containing the solution `.sln` file however you can change that in the Debugger settings of your project. – drescherjm Jan 19 '16 at 23:52
  • Perhaps this question is helpful: http://stackoverflow.com/questions/9163372/bitmapfromfile-returning-null-on-x86 – drescherjm Jan 19 '16 at 23:54

0 Answers0