Add bitmap to Resource file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I would like to add some images on resource file .resx; in this way I can
load the bitmap by code using GetObject method of ResourceManager class. I
suppose that this way to work is better than use Image.FromFile method...

How can I do that ? Can resource file resx be modified ?

Thank you in advance.

Keven Corazza
 
Easiest way is to add the images to your project and mark them as Embedded
Resource in the Properties window. Then in code you can do something like
this:
new
Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("NamespaceName.BitmapName.bmp"))

Obviously if you have something like a picturebox on a form you can directly
attach the Image to the control via the properties window (in that case
check out the code generated for you in the InitializeComponent to see what
it does).

Cheers
Daniel
 
Using the embedded resource approach in smartphone cause the application
load time to increase dramatically.
I wouldn't recommend it on smartphone platforms.

Miron
 
Back
Top