GDI+ Images Sample
This sample application shows how to manipulate images using GDI+.
To get samples and instructions for installing them
Do one or more of the following:
On the Help menu, click Samples.
The Readme displays information about samples.
Visit the Visual Studio 2008 Samples Web site. The most recent versions of samples are available there.
Locate samples on the computer on which Visual Studio is installed. By default, samples and a Readme file are installed in drive:\Program Files\Microsoft Visual Studio 9.0\Samples\lcid. For Express editions of Visual Studio, all samples are located online.
For more information, see Visual Studio Samples.
Security Note: |
---|
This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties. |
To run this sample
- Press F5.
Demonstrates
The following ideas are demonstrated in this sample:
Zoom The zoom feature changes the size of an image on the screen. The amount of zooming performed is generally expressed as a percentage of the original size of the image. Zooming does not change the size of the original image, only the image size that appears on the screen. This is demonstrated in the Zoom method of this sample.
Resize The resize feature changes the actual size of the image. Both the width and height are changed based on a resize ratio. This is demonstrated in the ResizeImage method of this sample.
Flip and Rotate Flipping reflects an image across either the x- or y-axis. The result is either a mirror image or an upside-down image. Rotating pivots the image a certain number of degrees about its center. For images, it is most common to rotate in multiples of 90 degrees. Rotating and flipping are demonstrated in the RotateFlip method of this sample.
Negative and Grayscale Creating a negative or grayscale image is done using a ColorMatrix. When applied to an image, the ColorMatrix is the basis for a color transformation. This is demonstrated in the DrawNegativeImage and ConverttoGrayScale methods of this sample.
Crop Cropping takes a region of an image and makes that region into its own separate image. This is demonstrated in the CropButton_Click method of this sample.
Thumbnails Images can be saved either in their normal size or as a thumbnail. One way to create a thumbnail is to create a clone of the image, resize it, and save the clone as a thumbnail. This is demonstrated in the SaveThumbnailAs_Click method of this sample.
See Also
Tasks
How to: Create Graphics Objects for Drawing
How to: Rotate, Reflect, and Skew Images
How to: Create Thumbnail Images