Browse DevX
Sign up for e-mail newsletters from DevX


Generate and Modify Images with GDI+  : Page 2

Use GDI+ and the System.Drawing classes to simplify the process of manipulating images.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Basic Image Manipulation
The sample form contains five button controls and one picture box control. The buttons initiate various image manipulation functions. The picture box displays the original image when the form first loads and the modified image after each manipulation. The application uses the sample image sample.gif for all image manipulations, so you'll need to copy the file to your hard disk, and then change the value of the constant strFileName so that it contains the pathname of the copied sample.gif file on your machine.

Loading Images
The simplest way to load an image is to call the System.Drawing.Image.FromFile method with the pathname of the file you want to load, for example:

img = System.Drawing.Image.FromFile(strFileName);

The FromFile method returns an Image object, which you can then manipulate or assign to the Image property of a PictureBox control.

pbImage.Image = img;

The method has a second optional Boolean parameter, with the exceptionally long name of useEmbeddedColorManagement, which controls whether the Image object uses any color correction information embedded in the file. The default value of the parameter is false.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date