loading images from files?

  • Thread starter Thread starter Mustafa Rabie
  • Start date Start date
M

Mustafa Rabie

hi i want to make my application skinnable. So i thought of having an XML
file that defines the skin, and then read the skin files and load the images
specified.
I know that in .Net there's image.FromFile() function that loads an image
from file, but can't find it in netCF. So how can i reach that?

Thanks
Mustafa
 
easiest way to do this is to include the image as an embedded resource in
your CF project
and at runtime use reflection to load it as a bitmap. here's a sample:

pbMap.Image = new
Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("{namespace}.Atlanta.bmp"));

there are other ways to do this and handle other image formats, but this
should get you started.
 
There is an overload for the Bitmap constructor which takes a filename e.g.

[C#]
Image i = new Bitmap("\\My Documents\\skinfile.jpg");

[VB]
Dim i As Image = New Bitmap("\My Documents\Skinfile.jpg")

Peter
 
thanks peter it worked
Peter Foot said:
There is an overload for the Bitmap constructor which takes a filename
e.g.

[C#]
Image i = new Bitmap("\\My Documents\\skinfile.jpg");

[VB]
Dim i As Image = New Bitmap("\My Documents\Skinfile.jpg")

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Mustafa Rabie said:
hi i want to make my application skinnable. So i thought of having an XML
file that defines the skin, and then read the skin files and load the
images specified.
I know that in .Net there's image.FromFile() function that loads an image
from file, but can't find it in netCF. So how can i reach that?

Thanks
Mustafa
 
Back
Top