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)MyNamesp ace.MyImageFile InMyProject.png ;
Something *close* to that would be great.
Thanks for any suggestions!
Steve 2 2091
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 GetManifestReso urceStream
method of the Assembly class.
You can use GetManifestReso urceNames, 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)MyNamesp ace.MyImageFile InMyProject.png ;
Something *close* to that would be great.
Thanks for any suggestions! Steve
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*******@yaho o.nospammin.com > wrote in message
news:06******** *************** ***********@mic rosoft.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 GetManifestReso urceStream method of the Assembly class. You can use GetManifestReso urceNames, 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)MyNamesp ace.MyImageFile InMyProject.png ;
Something *close* to that would be great.
Thanks for any suggestions! Steve This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 suggestion is as
follows:
Brendan, thanks for the reply!
I'm a little bit further now, but not yet finished.
I've come this far, see code below:
Stream s =
|
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 have to migrate the files
everywhere that the executable is installed. Is there a way to add them to a
Visual Studio solution/project so that they are embedded in the application
somehow? If so, how do I access the images when needed?
Thanks,...
|
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
--
Message posted via DotNetMonster.com
|
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 in the get resource code.
The code I'm using is:
System.Reflection.Assembly myAssembly;
myAssembly = this.GetType().Assembly;
|
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 path in the DLL). I
understand why it's happening, but instead of referencing a global path or
moving the file to the programs directory where I'm using the DLL, I was
wondering if it's possible to compile the image right into the DLL (or EXE
for...
| |
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?
|
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 Bitmap(GetType(),"HLP.BMP");
I got runtime error and it said
"System.ArgumentException: Resource 'HLP.BMP' could not be found in class
'testImage.Form1".
|
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 for the image so
that the image in the picture box and button control can be paint
transparently ?
Currently I'm using Magenta in my image portion which require
transparent effect.
|
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
these forms have a save button with an icon (along with other common
buttons and icons). At this point, we've added the icon to each
project.
Unfortunately, if we want to change the icon, we now have to go to
every project and change it. It would...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |