1

I have a program that Im using OpenFileName and GetOpenFileName to get a file and using Windows Imaging Component to convert it to a DIBSection then using BitBlt to draw it to the window.

I want to do the same with my resource files so I use LoadImage, but when I try to convert it using Windows Imaging Component I get an access violation and it says error reading characters of string.

This is how I use LoadImage

LoadImage(NULL,MAKEINTRESOURCE(IDB_BACKGROUND),0,0,0,LR_LOADFROMFILE);

Whats my problem here?

  • See [How to load a bitmap from a resource](http://msdn.microsoft.com/en-us/library/windows/desktop/dd756685(v=vs.85).aspx), which is part of a Direct2D sample application. – Roger Rowland Jun 13 '13 at 13:40

1 Answers1

4

DO not use LR_LOADFROMFILE as the last parameter. When this parameter is used, the function loads from a file. Pass NULL, or LR_SHARED (if you are planning to use it somewhere else in the program)

cha
  • 10,301
  • 1
  • 18
  • 26