How can I use resource file and embed a .jpg file to output executable?

thebluetropics 1,046 Reputation points
2022-10-19T10:02:48+00:00

My purpose is to be able to embed a .jpg file into the program executable in Visual Studio 2022, then I can use it with Direct2D using WIC.
I have zero experience of using .rc file. But I have tried to work with resource files using Visual Studio's resource editor, or whatever that called.
I prefer to manual writing of .rc file instead using managed tools...

I have background.jpg in my project folder, will this code work?

resource.rc

   BackgroundImage Image "background.jpg"  

Edit: I got this: 251955-screenshot-36.png

Windows development | Windows API - Win32
Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
0 comments No comments
{count} vote

Answer accepted by question author
  1. Castorix31 91,501 Reputation points
    2022-10-19T10:17:08.693+00:00

    Yes, you can load it as IStream, then convert it to WIC, like in this sample I had posted with a GIF : How to define a GIF image in resource file?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.