Embed bitmap into exe?

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Is there a way to embed a bitmap into the exe file created by Visual Studio?
And then create a Bitmap object from it at runtime?
 
Yes. Add bitmap to the project and in its properties set Action to Embedded
Resource. Then at the runtime use:
Dim bm as new
Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResource
Stream(strBitmapName))

Where strBitmapName is <Namespace>.<Bitmap file name>. Keep in mind that
strBitmapName is case-sensitive. If you are having troubles with figuring
out the exact bitmap name, enumerate the string array returned by
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames()
 
I added the bitmap to the project and set the Build Action to Embedded
Resource and that string is empty:

?
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames()
{Length=0}
 
I'm not at all sure it will work from the Command window. Do it from the
code

--
Alex Feinman
---
Visit http://www.opennetcf.org
Mike said:
I added the bitmap to the project and set the Build Action to Embedded
Resource and that string is empty:

?
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames()
{Length=0}



Alex Feinman said:
Yes. Add bitmap to the project and in its properties set Action to Embedded
Resource. Then at the runtime use:
Dim bm as new
Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResource
Stream(strBitmapName))

Where strBitmapName is <Namespace>.<Bitmap file name>. Keep in mind that
strBitmapName is case-sensitive. If you are having troubles with figuring
out the exact bitmap name, enumerate the string array returned by
System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames()
 
Back
Top