7.11. Saving Images with Different Sizes

Sometimes we need to save an image with a different size than it originally had. As we discussed earlier, the Save method of the Image class is used to save images. This method also allows us to specify the size of a saved image.

To make our program even more interesting, we will determine the size of the saved image at runtime. Create a Windows application and add two text boxes, two tables, and a button control to the form. The text boxes are used to specify the height and width of the saved image, and the button is used to save the image with the new size, as shown in Figure 7.42.

Figure 7.42. Saving images with different sizes

First we specify an Image private variable:

 private Image curImage; ...

Get Graphics Programming with GDI+ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.