473,241 Members | 1,864 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,241 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 2061
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: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.