473,715 Members | 5,945 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Embedding an image in a dll

UJ
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.Reflecti on.Assembly myAssembly;
myAssembly = this.GetType(). Assembly;

// Creates the ResourceManager .
System.Resource s.ResourceManag er myManager = new
System.Resource s.ResourceManag er("Marlin.Visu alControls",
myAssembly);

// Retrieves Image resource.
System.Drawing. Image myImage;
myImage =
(System.Drawing .Image)myManage r.GetObject("EC SStartupGraphic ");

I can't tell whether it's the resource manager that is set up wrong or the
get object is wrong (I have a feeling the resource manager is wrong.)

The namespace that the resource is in is Marlin.VisualCo ntrols. The name of
the object is ECSStartupGraph ic (I verified this through resource editor and
also by looking at the file.)

I've also added the file to the project and set it's Build Action as
Embedded Resource.

I just can't seem to get the references right.

And if I've got a window with this image on it (it will always be this
image) is there someway to tell it the file is a reference instead of trying
to look at the disk somewhere?

TIA - Jeff.
Mar 10 '06 #1
3 12125
Here's what I've cooked up:

string samplePath = "Modules.Invent ory.Resources.W I_ReviewIcon.pn g";

Image img = GetImageFromMan ifest(samplePat h);
/// <summary>
/// Convert an embedded image resource to a Drawing.Image object
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public Image GetImageFromMan ifest(string path)
{
Image newImage = null;
try
{
Assembly thisAssembly = Assembly.GetAss embly(this.GetT ype());
Stream resourceStream = thisAssembly.Ge tManifestResour ceStream(path);
newImage = Image.FromStrea m(resourceStrea m);
}
catch (Exception e)
{
System.Diagnost ics.Debug.Write Line(e.Message) ;
}
return newImage;
}

Hope that helps...

"UJ" <fr**@nowhere.c om> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
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.Reflecti on.Assembly myAssembly;
myAssembly = this.GetType(). Assembly;

// Creates the ResourceManager .
System.Resource s.ResourceManag er myManager = new

System.Resource s.ResourceManag er("Marlin.Visu alControls", myAssembly);

// Retrieves Image resource.
System.Drawing. Image myImage;
myImage =
(System.Drawing .Image)myManage r.GetObject("EC SStartupGraphic ");

I can't tell whether it's the resource manager that is set up wrong or the
get object is wrong (I have a feeling the resource manager is wrong.)

The namespace that the resource is in is Marlin.VisualCo ntrols. The name
of the object is ECSStartupGraph ic (I verified this through resource
editor and also by looking at the file.)

I've also added the file to the project and set it's Build Action as
Embedded Resource.

I just can't seem to get the references right.

And if I've got a window with this image on it (it will always be this
image) is there someway to tell it the file is a reference instead of
trying to look at the disk somewhere?

TIA - Jeff.

Mar 10 '06 #2
UJ
That worked great. Thanks. I think my main problem was not knowing the name
of the item to use but I figured it.

Jeff.

"sklett" <sk****@mddirec t.com> wrote in message
news:OM******** ******@TK2MSFTN GP11.phx.gbl...
Here's what I've cooked up:

string samplePath = "Modules.Invent ory.Resources.W I_ReviewIcon.pn g";

Image img = GetImageFromMan ifest(samplePat h);
/// <summary>
/// Convert an embedded image resource to a Drawing.Image object
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public Image GetImageFromMan ifest(string path)
{
Image newImage = null;
try
{
Assembly thisAssembly = Assembly.GetAss embly(this.GetT ype());
Stream resourceStream = thisAssembly.Ge tManifestResour ceStream(path);
newImage = Image.FromStrea m(resourceStrea m);
}
catch (Exception e)
{
System.Diagnost ics.Debug.Write Line(e.Message) ;
}
return newImage;
}

Hope that helps...

"UJ" <fr**@nowhere.c om> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
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.Reflecti on.Assembly myAssembly;
myAssembly = this.GetType(). Assembly;

// Creates the ResourceManager .
System.Resource s.ResourceManag er myManager = new

System.Resource s.ResourceManag er("Marlin.Visu alControls", myAssembly);

// Retrieves Image resource.
System.Drawing. Image myImage;
myImage =
(System.Drawing .Image)myManage r.GetObject("EC SStartupGraphic ");

I can't tell whether it's the resource manager that is set up wrong or
the get object is wrong (I have a feeling the resource manager is wrong.)

The namespace that the resource is in is Marlin.VisualCo ntrols. The name
of the object is ECSStartupGraph ic (I verified this through resource
editor and also by looking at the file.)

I've also added the file to the project and set it's Build Action as
Embedded Resource.

I just can't seem to get the references right.

And if I've got a window with this image on it (it will always be this
image) is there someway to tell it the file is a reference instead of
trying to look at the disk somewhere?

TIA - Jeff.


Mar 10 '06 #3
Hi,

"UJ" <fr**@nowhere.c om> wrote in message
news:%2******** *******@TK2MSFT NGP10.phx.gbl.. .
That worked great. Thanks. I think my main problem was not knowing the
name of the item to use but I figured it.


You need to use the complete name of the object, including the namespace
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Mar 10 '06 #4

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

Similar topics

1
3847
by: D. Yates | last post by:
Hi, I am looking for an example of how to extract bitmap images from an embedded resource file (a file with *.res extension, which can be viewed inside of the ide and can hold bitmaps, icons, string tables, etc.) and place them into a imagelist. I have found examples using the resource manager to create a "resource file" like so: ResourceWriter rw = new ResourceWriter (
4
1961
by: Marc Pelletier | last post by:
Hello, I have a class (TideClass) which creates a bitmap image as one of its functions. I want to create a page which has this image embedded amongst some text. I know that I have to stream the image back from a separate aspx page. I have therefore created a page Day1.aspx which gets the instance of tide from the context handler, calls the DrawChart function and streams it back.
0
1916
by: Robin Tucker | last post by:
At the moment I have place-holders in my Word document (before you say it, yes I've posted this query in the VBA newsgroups but they are a little slow - in fact reply was non-existent!). I'm running through the document, finding the placeholders (which are jpeg images) and replacing them with OLE objects, the location of which is stored in a hyperlink on the image. The reason I'm doing this is because my reporting package flattens OLE...
7
2432
by: David Thielen | last post by:
Hi; Is there a way to embed images in the response rather than writing them to disk and having an <img ...> tag? And if so, how is it done and what browsers support it? -- thanks - dave
2
1545
by: Nick Douglas | last post by:
We want our company logo to appear on the forms in our database. The logo is on our homepage. Is there a way to link it? (rather than embed it).
6
22805
by: Edward | last post by:
I have been doing some research about embedding images in HTML using the data URL src method of the format: <img src="/-/data:image/gif;base64,<DATA>"> My question is, how does one generate this <DATA> string? I have found some on the web that I can load into my browser but if I save this image and then view in Notepad it looks much different than the string that I used in <DATA> and is full of non-alphanumeric symbols. Also, I have...
1
5194
by: MissMarie | last post by:
I've been playing around with DIV tables in myspace to better learn how to rewrite my own code for my business site without having to pay someone to design it. I've tried embedding a slideshow into a div table and after I save it I noticed that the slideshow does not show up and the embed code I added is altered. Can anyone help me figure this out? The embed code that I'm talking about is three quarters down the code page under {PHOTOS},...
0
1152
by: lhoracio | last post by:
Hi, I've got a small app in VB6 with MySQL. Works fine, but I found I would need to embedd some images on text displayed in a RTF control. I have no problem in pasting it to the control. Another form copies and pastes the selected image on this control. But I simply can't save it. Image is not saved, and if I save it directly to the DB, it won't show the image. What am I doing wrong here?
0
1149
by: shg | last post by:
Hi, I am creating an XML file that I will provide to my customers for use. The XML file contains information about some rawdata and Images. Now my main concern is how should I provide information about the images. If I provide the link then it will increase the number of hits on my server (performance will decrease) and If I provide raw information like pixel values then It will increase the size of XML to 10times the size of Original...
7
7463
by: pavan anumula | last post by:
I have a requirement When i click on button, i have to initiate an email with the to address, subject, and body should contain an image and the text . Problem : I cannot embed the image using 'mailto' (javascript) . Please provide solutions for embedding image to the outlook or any email generator like outlook(if not present). Thanks in Advance.
0
8821
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, 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...
0
9340
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, 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...
1
9103
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9047
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6646
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5967
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4738
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2539
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2118
bsmnconsultancy
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...

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.