473,397 Members | 1,972 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,397 software developers and data experts.

Use image in project as a resource

I've got a couple images in my project that I need to pass to some other
assemblies. I waned to pass them as an Image object. I was hoping there
was some way that I could load the images files without needing to use the
full path and Image.FromFile() - it seems that there should be some way to
reference assets in the project without giving their full path. Anyone know
how?

For example, I would like to do something like this:
Image myIMage = (Image)MyNamespace.MyImageFileInMyProject.png;

Something *close* to that would be great.

Thanks for any suggestions!
Steve
Feb 12 '06 #1
2 2066
Steve,
if the image is included in the project and has been marked as "Embedded
Resource" then you can gain access to it with the GetManifestResourceStream
method of the Assembly class.
You can use GetManifestResourceNames, which returns a string array, to see
exactly how each resource can be referred to.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"sklett" wrote:
I've got a couple images in my project that I need to pass to some other
assemblies. I waned to pass them as an Image object. I was hoping there
was some way that I could load the images files without needing to use the
full path and Image.FromFile() - it seems that there should be some way to
reference assets in the project without giving their full path. Anyone know
how?

For example, I would like to do something like this:
Image myIMage = (Image)MyNamespace.MyImageFileInMyProject.png;

Something *close* to that would be great.

Thanks for any suggestions!
Steve

Feb 13 '06 #2
Perfect, thanks Peter!
I'm actually using a class library, so I had a little more research to get a
reference to my Assembly, but it works great now. Appreciate your help.

-Steve

"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:06**********************************@microsof t.com...
Steve,
if the image is included in the project and has been marked as "Embedded
Resource" then you can gain access to it with the
GetManifestResourceStream
method of the Assembly class.
You can use GetManifestResourceNames, which returns a string array, to see
exactly how each resource can be referred to.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"sklett" wrote:
I've got a couple images in my project that I need to pass to some other
assemblies. I waned to pass them as an Image object. I was hoping there
was some way that I could load the images files without needing to use
the
full path and Image.FromFile() - it seems that there should be some way
to
reference assets in the project without giving their full path. Anyone
know
how?

For example, I would like to do something like this:
Image myIMage = (Image)MyNamespace.MyImageFileInMyProject.png;

Something *close* to that would be great.

Thanks for any suggestions!
Steve

Feb 13 '06 #3

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

Similar topics

6
by: Saya | last post by:
Hello, This is a repost 'cause I haven't solve the problem: I can't use the System.Drawing class 'Image.FromStream' in the CompactFramework environment. What I've done with respect to Brendan's...
2
by: Don Tucker | last post by:
Hello, I have a Windows Application that needs to load multiple image files in response to users clicking buttons. Currently, I just have these images as .jpg files on disk, but I don't want to...
5
by: aiki727 via DotNetMonster.com | last post by:
Hello everyone, Where do I store a bitmap or jpeg that I am using for a forms background image when I deploy the application? Or do I link these files to the app during the deployment? Thanks...
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...
5
by: Mark Denardo | last post by:
I have a DLL that I created that contains a reference to an image file on my hard drive and when I go to use that DLL in another program it complains that it can't find it. (I'm using a relative...
2
by: Patrick F | last post by:
Hi, i have a resourcefile with my project that contains a jepg image. Now i want to retrive that image to a Image m_Image in my program. Whats the best way to do this?
2
by: keith | last post by:
I created a subdirectory in a project and added an image to the subdirectory from the project and set its property Build Action=Embedded Resource. Then instanciate a image by Image img=new...
0
by: jcvoon | last post by:
Hi: I'm using VS2005, I add my image into project resource file, and my picture box and button control reference the image from the project resource file, what is the default transparent color...
3
by: bbrewder | last post by:
I am interested in hearing how other people have handled sharing resources in multiple projects (for example, a save icon). We have a product that has many forms within many projects. Many of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.