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 / Windows Forms / Design Time / November 2005

Tip: Looking for answers? Try searching our database.

incorporating an image at design time

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gregory Khrapunovich - 08 Nov 2005 14:47 GMT
I am working on the C#/Windows Forms project. Currently I am displaying
images using Bitmap objects that I create at runtime from .jpg files. It
means that I have to distribute all .jpg files with the application. Is
there a way to incorporate .jpg images at design time, so I won't have to
redistribute them?
Gregory Khrapunovich
Tim Wilson - 08 Nov 2005 17:15 GMT
You can add each jpg to your project and set there Build Action to Embedded
Resource. This way the jpg will be embedded in the output assembly and you
can load each jpg when needed using the GetManifestResourceStream method.
Note that this assumes that you're using VS.NET 2003. In VS 2005 you can
could use the project properties and the resulting strongly typed resource
access that it creates.

Signature

Tim Wilson
.NET Compact Framework MVP

> I am working on the C#/Windows Forms project. Currently I am displaying
> images using Bitmap objects that I create at runtime from .jpg files. It
> means that I have to distribute all .jpg files with the application. Is
> there a way to incorporate .jpg images at design time, so I won't have to
> redistribute them?
> Gregory Khrapunovich
Bajoo - 11 Nov 2005 06:48 GMT
Dear Gregory,
                   After you have change the files to Embedded
resource, you can get the image by using the following code

Assembly myAssembly = Assembly.GetExecutingAssembly();
Stream myStream =
myAssembly.GetManifestResourceStream("ABC.XYZ.Resource." +
ImageMap[buttonCaption].ToString());
Image image = new Bitmap(myStream);

I hope it helps
Regards,
Naveed Ahmad Bajwa
http://bajoo.blogspot.com/
Bajoo - 11 Nov 2005 08:02 GMT
Dear Gregory,
                   After you have change the files to Embedded
resource, you can get the image by using the following code

Assembly myAssembly = Assembly.GetExecutingAssembly();
Stream myStream =
myAssembly.GetManifestResourceStream("ABC.XYZ.Resource." +
ImageMap[buttonCaption].ToString());
Image image = new Bitmap(myStream);

I hope it helps
Regards,
Naveed Ahmad Bajwa

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.