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 Visual Studio Other
0 comments No comments
{count} vote

Accepted answer
  1. Castorix31 90,681 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 Answers by the question author, which helps users to know the answer solved the author's problem.