title: Is there a way to preserve the BITMAPFILEHEADER when loading a Bitmap as a Windows resource?
body: <p>I've been working on testing a few things out using <a href="http://sfml-dev.org/" rel="nofollow noreferrer">SFML 1.4</a> (Simple and Fast Multimedia Library) with C++ and Visual C++ 2008 Express Edition.  To avoid having external images with my graphical programs, I was testing out the <a href="http://www.sfml-dev.org/documentation/1.4/classsf_1_1Image.htm#72565ffabe12dfb2602e209c2e6f0486" rel="nofollow noreferrer">sf::Image::LoadFromMemory(const char * Data, std::size_t SizeInBytes)</a> function with Bitmap resources loaded using a simple resource script:</p>
  
  <pre><code>IDB_SPRITE BITMAP "sprite1.bmp"
  </code></pre>
  
  <p>In my code to load the image to create an <a href="http://www.sfml-dev.org/documentation/1.4/classsf_1_1Image.htm" rel="nofollow noreferrer">sf::Image</a> using this bitmap resource, I use the following procedure, consisting of Win32 API functions (I've excluded the code that checks to make sure the Win32 functions don't return NULL to shorten this a bit):</p>
  
  <pre><code>HRSRC hResInfo = FindResource(NULL, MAKEINTRESOURCE(IDB_SPRITE), RT_BITMAP);
  HGLOBAL hResData = LoadResource(NULL, hResInfo);
  char * resourceData = reinterpret_cast&lt;char *&gt;(LockResource(hResData));
  </code></pre>
  
  <p>After that, I use the sf::Image::LoadFromMemory function:</p>
  
  <pre><code>MyImage.LoadFromMemory(resourceData, SizeofResource(NULL, hResInfo));
  </code></pre>
  
  <p>However, this doesn't work (I get an unknown file type error).  After some testing, I discovered that the bitmap data I pass to the LoadFromMemory function does not include the BITMAPFILEHEADER (the first 14 bytes), and I believe this is the cause of the unknown file type error.</p>
  
  <p>I can restore the BITMAPFILEHEADER manually and get the LoadFromMemory function to work fine.  <strong>However, I'm wondering if there is some way to preserve the BITMAPFILEHEADER in the resource data to avoid doing this?</strong></p>