Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

icons and bitmaps

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Analizer1 - 04 Mar 2008 15:52 GMT
I would like to place some icons and small bitmaps in a dll, but im not sure
how to go about this using c#

any Suggestions Welcome
thanks
Paul E Collins - 04 Mar 2008 16:08 GMT
> I would like to place some icons and small bitmaps in a dll, but im
> not sure how to go about this using c#

Add the files to your project and change the Build Action property for
each file to "Embedded Resource".

You can access them in code using Assembly.GetManifestResourceStream.

Eq.
Analizer1 - 04 Mar 2008 20:32 GMT
Where can i Find a Example...
Ive not used Assembly before

thanks

>> I would like to place some icons and small bitmaps in a dll, but im not
>> sure how to go about this using c#
[quoted text clipped - 5 lines]
>
> Eq.
Paul E Collins - 04 Mar 2008 21:39 GMT
> [icons and bitmaps in a DLL]
> Where can i Find a Example...
> Ive not used Assembly before

Well, here is a quick example if you just want to retrieve a bitmap. If
it's not enough, you should check the Visual Studio documentation and
also make sure you know about the Stream class.

using System.Reflection;
. . .
Bitmap b = (Bitmap) Bitmap.FromStream(
 Assembly.GetExecutingAssembly().GetManifestResourceStream(
 "MyNamespace.MyImageFilename.bmp"
 ));

This works if your code is in a namespace "MyNamespace" and you've added
a file "MyImageFilename.bmp" with Build Action set to "Embedded
Resource".

Eq.
Analizer1 - 04 Mar 2008 22:13 GMT
below is code i have working....
What if the icon/image is stored in another dll
How would i go about retrieving that icon/image
Assembly assembly = Assembly.GetExecutingAssembly();

// Retrieve a list of resource names contained by the assembly.

string[] resourceNames = assembly.GetManifestResourceNames();

foreach (string resourceName in resourceNames)

{

Console.WriteLine(resourceName);

}

// Retrieving an image resource follows the same principle.

string ResourceName = string.Format("{0}.{1}", assembly.GetName().Name,
"STOP.ICO");

Console.WriteLine(ResourceName);

using(Stream barStream = assembly.GetManifestResourceStream(ResourceName))
//barResourceName)))

{

using (Icon oIcon = new Icon(barStream))

{

Bitmap oBitmap = oIcon.ToBitmap();

this.pictureBox1.Image = oBitmap;

}

}

>> [icons and bitmaps in a DLL]
>> Where can i Find a Example...
[quoted text clipped - 15 lines]
>
> Eq.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.