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

Retrieving an Image from a resource file

I'm using VS2k5 and i've added a bunch of images to the project's
resource.resx file and thus they reside in the Resources folder. I want to
dynamically add an image to my project. I have no problem adding an image
if its part of an existing UserControl or Form, but just as part of the
general project, I can't seem to figure out how to obtain the info via the
ComponentResourceManager.

Thanks in advance.

dh
Jan 21 '06 #1
1 4243
Find the correct resource imageName looking at your assembly Manifest (use
ildasm), then try this...

public Bitmap getBitmap( string imageName, t
AnyTypeWithinTheSameAssemblyNamespace ) {

Assembly myAssembly = Assembly.GetAssembly(t);

Stream myStream = myAssembly.GetManifestResourceStream( t, imageName );

Bitmap b = new Bitmap(myStream, true);

myStream.Close();

// Get the current desktop screen graphics.

Graphics g = Graphics.FromHwnd(IntPtr.Zero);

// Make a bitmap using that color depth.

Bitmap bitmap = new Bitmap(b.Width, b.Height, g);

// Clean up.

g.Dispose();
// Start drawing on our new bitmap.

g = Graphics.FromImage(bitmap);

// Copy the loaded bitmap to the bitmap with proper screen depth.

g.DrawImage(b, 0, 0, bitmap.Width, bitmap.Height);

// Clean up.

g.Dispose();

b.Dispose();
return bitmap;

}

"Doug Handler" <dk*******@yahoo.com> wrote in message
news:OV**************@tk2msftngp13.phx.gbl...
I'm using VS2k5 and i've added a bunch of images to the project's
resource.resx file and thus they reside in the Resources folder. I want
to dynamically add an image to my project. I have no problem adding an
image if its part of an existing UserControl or Form, but just as part of
the general project, I can't seem to figure out how to obtain the info via
the ComponentResourceManager.

Thanks in advance.

dh

Jan 21 '06 #2

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

Similar topics

1
by: Roman Kagan | last post by:
Hi everyone, I am successful in retrieving the image from the table (.TIF), however, the retrieved file does not work. It looks like an image file - extension, size and all, but the image is not...
4
by: Matthew Wieder | last post by:
I have a form which contains a picturebox control which displays a gif image. By default, the image that was selected when I designed the dialog gets stored in the resx file and gets compiled and...
1
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,...
7
by: Robert W. | last post by:
I think I'm going insane, but thought I'd check with you all first before I get myself commited! Here's a method I've built to retrieve an image: public static Image GetImage(string...
6
by: Dean Slindee | last post by:
Does anybody have an actual example of retrieving an Image data type column from a SQL Server table using a dataset (not a datareader)? I would like to see the statements that would move the...
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...
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...
2
by: shivapadma | last post by:
i have inserted the image into database using the following code String driverName = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost:3306/"; String dbName =...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
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...
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: 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:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
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.