[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Graphics' (#lcl)

# TRasterImage.SaveToStream

Saves image data to the specified stream.

## Declaration

Source position: graphics.pp line 1321

`public procedure TRasterImage.SaveToStream(`
`AStream: TStream`
`); override;`

## Arguments

`AStream` |  | Stream where the image data is stored.

## Description

SaveToStream is an overridden method used to write image data to the stream specified in AStream.

SaveToStream calls SaveStreamNeeded to ensure that an internal save stream exists in the class instance. An EInvalidGraphicOperation exception is raised in SaveStreamNeeded when the active update count for the count is not 0 (zero). An FPImageException is raised when a TMemoryStream instance could not be created and initialized in SaveStreamNeeded.

SaveToStream resets the internal save to stream to its origin, and resizes AStream to include sufficient storage for the values in the internal save stream. The CopyFrom method in AStream is called to store the content for the internal shared image. An FPImageException is raised when the number of bytes written in the CopyFrom method does not match the size for the internal save stream.

## Errors

Raises an FPImageException exception when the number of bytes written to the stream does not match the size for the raw image data.

An Exception may be raised in SaveToStream (called in the method).

## See also

TGraphic.SaveToStream |  | SaveToStream - write graphic data to a stream.