473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How best to load an image resource?

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/de...sInProject.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?

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #1
2 8980
I believe this was discussed a day or two ago not exactly your problem but
something like it, maybe looking at this:

http://msdn.microsoft.com/newsgroups...sloc=en-us&p=1

will point you in the right direction.

Hope that helps
Mark.

"Robert W." wrote:
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/de...sInProject.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?

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #2
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?

--
Robert W.
Vancouver, BC
www.mwtech.com

"Mark R. Dawson" wrote:
I believe this was discussed a day or two ago not exactly your problem but
something like it, maybe looking at this:

http://msdn.microsoft.com/newsgroups...sloc=en-us&p=1

will point you in the right direction.

Hope that helps
Mark.

"Robert W." wrote:
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/de...sInProject.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?

--
Robert W.
Vancouver, BC
www.mwtech.com

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
4
by: Ed Sutton | last post by:
I have been searching for how to get an icon resource and load it into an ImageList. I added an *.ico file to my project and set the files "Build Action" to "Embedded Resource". Is there any easy...
2
by: Fernando Lopes | last post by:
Hey there! Someone knows how can I get and show an embbed resource image? I'm developing a web custom control and this control have some images and I want to put all these images like a embbed...
5
by: Paul Cheetham | last post by:
Hi, I have some custom colour cursors which I have added to my c# project, and set them to be compiled as "Embedded Resource" It seems impossible to load a colour cursor using the standard...
3
by: UJ | last post by:
I've got an image I want to embed in a dll to use on a screen later. I've got it in a resource file, got it to compile in to the dll. The problem is getting it back out. It seems like my problem is...
0
by: poojo hackma | last post by:
How can I load a System Resource image into a PictureBox with the CLR? Code: //----------------------------------------- System::Windows::Forms::PictureBox^ PictureBox1; System::IO::Stream^...
8
by: John Dunn | last post by:
Since currently we aren't allowed to have compiled XAML files embedded in C++ apps I'm using Markup::XamlReader::Load to dynamically load XAML files. This works perfectly fine with external files...
2
by: Yoavo | last post by:
Hi, In my application I need to load a bitmap which exists on an external DLL. How do I do it ? Yoav.
8
by: john_woo | last post by:
Hi, I'm wondering whether it is possible that makes page load image only on demand. is there any idea? -- Thanks John
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.