all groups > dotnet windows forms designtime > november 2005 >
You're in the

dotnet windows forms designtime

group:

incorporating an image at design time



Re: incorporating an image at design time Tim Wilson
11/8/2005 12:00:00 AM
dotnet windows forms designtime: 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.

--
Tim Wilson
..NET Compact Framework MVP

[quoted text, click to view]

incorporating an image at design time Gregory Khrapunovich
11/8/2005 9:47:29 AM
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

Re: incorporating an image at design time Bajoo
11/10/2005 10:48:37 PM
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/
Re: incorporating an image at design time Bajoo
11/11/2005 12:02:47 AM
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
AddThis Social Bookmark Button