Click here to Skip to main content
15,887,394 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it possible include images as resources in a win32 c++ executable? If so,how?

I am using compiler of visual studio.
Posted
Updated 9-Jul-14 23:00pm
v2
Comments
Legor 10-Jul-14 4:18am    
What compiler are you using?
RupeshMote 10-Jul-14 4:58am    
I am using compiler of visual studio
JJMatthews 11-Jul-14 3:47am    
what type of image are you trying to use (png, jpg, bmp)? why do you want this image in your project, what do you want to do with it after you add it to your resources ... display it on a dialog? what version of visual studio do you have?
RupeshMote 11-Jul-14 4:16am    
1) I am using .png types of images.
2) After including images to resource, I want to do template matching with input image & images from resource. So I don't want to keep template images on client PC. Instead, I want these template images include/store directly in .exe file.
3) I am using VS2012.
JJMatthews 11-Jul-14 7:40am    
sounds interesting ... one last question: do you need to put the images into the resource table in at design time or run time?

It is possible

In your solution view, click on the <your name="">.rc file to open the resource view.
Right click on the .rc file and select "Add Resource".
Now you will open a dialog box with options for Bitmap, Cursor, Icon etc.

You can also do Custom types as a BLOB, for example an embedded DLL.
 
Share this answer
 
Comments
Legor 10-Jul-14 4:19am    
Possible allthough he didn't mention that he uses Visual Studio.
George Jonsson 10-Jul-14 4:26am    
True. Maybe a faulty assumption from my side.
Legor 10-Jul-14 7:31am    
Well he updated now so it was a correct assumption ;)
RupeshMote 11-Jul-14 4:52am    
I did as per your Solution 1 and add a bitmap image. But when I run my project.exe file on client's computer, then it gives error that "image does not found".
And when I kept that image on client computer in that .exe folder, then it runs.

So I don't want to keep the image on client computer.

I want that image should be included in .exe file.

Is it possible?
Another possibility is to use the tool bin2c. You can use it to generate C-Code from binary files (e.g. .jpg .png .exe ...) which then can be embedded in your C/C++ applications.

You can get the tool here: http://sourceforge.net/projects/bin2c/[^]
 
Share this answer
 
v2
Comments
RupeshMote 10-Jul-14 5:07am    
Thanks
Legor 10-Jul-14 7:30am    
Your welcome, please accept the Solution if it helped solving your poblem.
RupeshMote 11-Jul-14 1:20am    
I did as per your Solution 1 and add a bitmap image. But when I run my project.exe file on client's computer, then it gives error that "image does not found".
And when I kept that image on client computer in that .exe folder, then it runs.

So I don't want to keep the image on client computer.

I want that image should be included in .exe file.

Is it possible?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900