Load image from resources area of project in C#

Pavel Bastov picture Pavel Bastov · Jul 28, 2009 · Viewed 515.2k times · Source

I have an image in my project stored at Resources/myimage.jpg. How can I dynamically load this image into Bitmap object?

Answer

Matt Hamilton picture Matt Hamilton · Jul 28, 2009

Are you using Windows Forms? If you've added the image using the Properties/Resources UI, you get access to the image from generated code, so you can simply do this:

var bmp = new Bitmap(WindowsFormsApplication1.Properties.Resources.myimage);