TPicture.SaveToStreamWithFileExt procedure
Saves graphic image data to a stream using the specified format and file extension.
Declaration
procedure SaveToStreamWithFileExt(Stream: TStream;
const FileExt: string)Arguments
Stream | Stream instance where the image data for the picture is stored. |
FileExt | File extension for the format used to write image data to the specified stream. |
Description
SaveToStreamWithFileExt is a method used to store image data found
in the Graphic property to the TStream instance specified in
Stream. It ensures that supported TGraphicClass class types in
Graphic are handled properly when accessing and storing the image data.
No actions are performed in the method if the Graphic property has not been assigned (contains Nil).
FileExt is the file extension for the graphics class used to write
the image data to the specified stream. It can differ from the format used in
Graphics, and can contain any of the graphics classes supported in the LCL
implementation. It must include the '.' separator for the file extension. For
example: '.jpg', '.png', or '.ico'.
The FindGraphicClassWithFileExt method is used to get a graphic class when a file extension has been provided in FileExt. An EInvalidGraphic exception is raised if FileExt contains an invalid graphics format for the current platform.
When FileExt is omitted, or contains the same extension used in Graphic, the SaveToStream method in the TGraphic instance is called to store the image data. No conversion is needed for the values written to Stream.
SaveToStreamWithFileExt provides support for conversion of image data for TFPImageBitmap descendants using their GetWriterClass methods. The raw image data is accessed and stored to Stream using the SaveToStream method found in the writer class.
If Graphic is derived from TCustomIcon, support is provided for converting the current icon image in Graphic to the specified file extension. The TCustomIcon.ExportImage method is used to write the icon image data.
An Exception is raised if Graphic does not support conversion to the file extension specified in the FileExt argument.
Modified in LCL version 4.2 to save individual images in TCustomIcon to another raster image format.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
