Home

SpeakComputers.com | Text-to-Speech Software

Natural sounding TTS voice support | Cepstral TTS voices | Text to MP3 | Natural Readers

Text to Speech Software Text to Speech Voices SpeakComputer Text to Speech Software

System.IO and Embedded Images.

Using Images with .net controls is really easy. The choice you need to make, is whether the image will be embedded into the application or whether the image will be a local resource (in a file on the users hard drive).

Images from files or on the users local hard drive has the advantage of a quick and easy image change without needing to re-install any software. But of course, if the user deletes, moves or renames the image files for what ever reason, the application will look incomplete or could crash due to lack of error checking.

Images used from within your application (Embedded Resource) offer protection of accidental deletion, renaming and moving. Images and other objects used by method of Embedded resources also offer a application performance increase over those using File methods. The only single disadvantage to using Embedded resources is if for what ever reason you need to change an image, you will need to reinstall the application. 

Look at the differences between embedded and file access images within your software. Should you embed images in your application. It all depends on what you want to achieve. Most software packages use a cobination of both embedded images and file images.

Assigning images to Controls that support Images.

Using the Image.FromFile method.
System.IO.FileInfo fileInfo = new System.IO.FileInfo(@"c:\Icons\helloworld.gif");

//Check if the file exists. If the file exists, assign the image to the control.
if (fileInfo.Exists) { this.button1.Image = Image.FromFile(@"c:\Icons\helloworld.gif"); }

Using an Image.FromStream Method.
Here we are going to assign an Image to a checkBox control, but this time the image will be an embedded resource file.

System.IO.Stream imageStream = this.GetType().Assembly.GetManifestResourceStream("Controls.002-folder_add.png"); checkBox1.Image = Image.FromStream(imageStream);

Here the "Controls.002-folder_add.png" breaks down to 2 parts.
Firstly the "Controls" is the name of my NameSpace. Secondly the 002-folder_add.png is the name of my Imag file.

Using an Image from the Global Resource File.
checkBox1.Image = global::Controls.Properties.Resources._412_forward;

Using an Image from an Image List.
Here we need to assign an ImageList to the controls ImageList property. Then we will assign an index value from the ImageList.
button1.ImageList = this.imageList1;
button1.ImageIndex = 0;

Infragistics Controls.
Infragistics Controls offer all the same Image methods as in the Windows Controls. You might find some property name changes. Below are some examples:

Using an Image.FromFile Method.
System.IO.FileInfo fileInfo = new System.IO.FileInfo(@"c:\Icons\helloworld.gif"); if (fileInfo.Exists) { this.ultraButton1.Appearance.Image = Image.FromFile(@"c:\Icons\helloworld.gif"); }

Using an Image from an ImageList.
First we assign an ImageList to the ImageList property, then we assign an index value to the image property.
this.ultraButton1.ImageList = this.imageList1;
this.ultraButton1.Appearance.Image = 3;

Using an Image from an Embedded resource via a Stream.
System.IO.Stream imageStream = this.GetType().Assembly.GetManifestResourceStream("Controls.1.gif"); this.ultraButton1.Appearance.Image = Image.FromStream(imageStream);
Top of page
Text to Speech Speech synthesis Software TTS Software
Copy Right 2006 SpeakComputers.com - All Rights Reserved.
About Privacy Policy TTS Resouces
Free Text to Speech software
Free Text to Speech Software