Image.Save Method (Stream, ImageFormat)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Saves this image to the specified stream in the specified format.

Namespace:   System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

Public Sub Save (
	stream As Stream,
	format As ImageFormat


Type: System.IO.Stream

The Stream where the image will be saved.

Type: System.Drawing.Imaging.ImageFormat

An ImageFormat that specifies the format of the saved image.

Exception Condition

stream or format is null.


The image was saved with the wrong image format

You should avoid saving an image to the same stream that was used to construct it. Doing so might damage the stream.

The image must be saved to the stream at an offset of zero. If any additional data has been written to the stream before saving the image, the image data in the stream will be corrupted.

.NET Framework
Available since 1.1
Return to top