--- title: "How to: Crop and Scale Images" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "images [Windows Forms], cropping" - "images [Windows Forms], scaling" ms.assetid: 053e3360-bca0-4b25-9afa-0e77a6f17b03 --- # How to: Crop and Scale Images The class provides several methods, some of which have source and destination rectangle parameters that you can use to crop and scale images. ## Example The following example constructs an object from the disk file Apple.gif. The code draws the entire apple image in its original size. The code then calls the method of a object to draw a portion of the apple image in a destination rectangle that is larger than the original apple image. The method determines which portion of the apple to draw by looking at the source rectangle, which is specified by the third, fourth, fifth, and sixth arguments. In this case, the apple is cropped to 75 percent of its width and 75 percent of its height. The method determines where to draw the cropped apple and how big to make the cropped apple by looking at the destination rectangle, which is specified by the second argument. In this case, the destination rectangle is 30 percent wider and 30 percent taller than the original image. The following illustration shows the original apple and the scaled, cropped apple. ![Screenshot of an original image and the same image cropped.](./media/how-to-crop-and-scale-images/original-image-cropped-image.png) [!code-csharp[System.Drawing.WorkingWithImages#11](~/samples/snippets/csharp/VS_Snippets_Winforms/System.Drawing.WorkingWithImages/CS/Class1.cs#11)] [!code-vb[System.Drawing.WorkingWithImages#11](~/samples/snippets/visualbasic/VS_Snippets_Winforms/System.Drawing.WorkingWithImages/VB/Class1.vb#11)] ## Compiling the Code The preceding example is designed for use with Windows Forms, and it requires `e`, which is a parameter of the event handler. Make sure to replace `Apple.gif` with an image file name and path that are valid on your system. ## See also - [Images, Bitmaps, and Metafiles](images-bitmaps-and-metafiles.md) - [Working with Images, Bitmaps, Icons, and Metafiles](working-with-images-bitmaps-icons-and-metafiles.md)