How best to load an image resource?

G

Guest

I want to create a special DLL that will contain only images. My application
will then load these images when it needs them. So I searched MSDN and found
this article:
http://msdn.microsoft.com/library/d...tml/vbtskEmbeddingImageResourcesInProject.asp

I followed the example but could not get it to work. Specifically, here's
my code:

Assembly myAssembly = Assembly.GetExecutingAssembly();
Stream myStream =
myAssembly.GetManifestResourceStream("DataObjects.test1.jpg");
Bitmap image = new Bitmap(myStream);

this.ClientSize = new Size(image.Width, image.Height);
pictureBox1.Image = image;


Notes:
- My DLL is called "DataObjects" and so is the namespace therein
- I loaded a sample image "test1.jpg" into the DLL and recompiled it

But the code fails on the 2nd line: "Stream myStream"

What am I doing wrong?
 
G

Guest

Hi Mark,

I clicked on that link in 2 different browsers but it's not bringing up any
specific topic. Could you give me the name of a title or some keywords to
find the thread you're referring to?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top