locked
How to load bitmap resource in C++ Windows Runtime Component?

    Question

  • Hello,

    I'm developing C++ Windows Runtime Component (to use it in my Windows Store App) with VisualStudio 2013:
    File->New Project->New...->Templates->Visual C++->Windows Store->Windows Runtime Component

    I use 'Add Resources' option in Solution Explorer:
    Add->Resources...->Bitmap->New

    Then I see 2 new files: WindowsRuntimeComponent1.rc and bitmap1.bmp.

    My question is: how to load bitmap1.bmp (IDB_BITMAP1) bytes in my component? (FindResource/ LoadResource pair is not available for Windows Store Apps?)

    Thanks,

    Yury

    Tuesday, January 21, 2014 11:43 AM

Answers

  • You cannot use resource files to like that in Windows Store apps. As you note, LoadResource, etc. are not available. In theory you could open the binary with file API to read out the resource, but typically you would include your bitmap assets loose as content in the app package rather than embedding them in the binary.

    Image resources can be added since they are used for Cursors, but aren't intended for general use by the app otherwise.

    Thursday, January 23, 2014 3:29 PM
    Owner

All replies

  • See http://code.msdn.microsoft.com/windowsapps/Application-resources-and-cd0c6eaa

    To load a .bmp, use the Windows Imaging Component (WIC).

    Wednesday, January 22, 2014 7:00 AM
  • Correct.

    I want to load image bytes and then use  m_pIWICFactory->CreateStream API as described in 'how-to'

    http://msdn.microsoft.com/en-us/library/windows/desktop/ee719660%28v=vs.85%29.aspx

    But how to load resource image in Windows Runtime Component?

    Visual Studio 2013 allows to add resource as *.rc file in WRC project template.

    But how to get image bytes from resource?

    Thursday, January 23, 2014 2:16 PM
  • You cannot use resource files to like that in Windows Store apps. As you note, LoadResource, etc. are not available. In theory you could open the binary with file API to read out the resource, but typically you would include your bitmap assets loose as content in the app package rather than embedding them in the binary.

    Image resources can be added since they are used for Cursors, but aren't intended for general use by the app otherwise.

    Thursday, January 23, 2014 3:29 PM
    Owner
  • Thanks Rob,

    I wondered why I can add resource in WRC project and can't use and you have clarified it :)

    Thursday, January 23, 2014 4:08 PM