GDI+ Images Sample

To get samples and instructions for installing them, see the following:

  • Click Samples on the Visual Studio Help menu.

    For more information, see Locating Sample Files.

  • The most recent versions and the complete list of samples are available on the Visual Studio 2008 Samples Web site.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied to a folder under \Program Files\Visual Studio 9\Samples\. For Visual Studio Express Editions, all samples are located on the Internet.

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.