Unit 'Graphics' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#lcl]

TPicture.SaveToStreamWithFileExt

Saves graphic image data to a stream using the specified format and file extension.

Declaration

Source position: graphics.pp line 927

public procedure TPicture.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.

Version info

Modified in LCL version 4.2 to save individual images in TCustomIcon to another raster image format.

See also

TPicture.Graphic

  

Graphic - The TGraphic object contained by the TPicture.

TPicture.FindGraphicClassWithFileExt

  

Finds a graphic class with the named file extension Ext, and raises an exception if not found.

TCustomIcon

  

TCustomIcon - base class for TIcon.

TCustomIcon.ExportImage

  

Exports the image for the icon at the specified index to another TFPImageBitmap class instance.

TCustomIcon.Current

  

Ordinal position for the current image displayed for the icon.

TFPImageBitmap

  

Implements a Bitmap using the FPImage reader and writer from the FCL.

TGraphicClass

  

TGraphicClass - class of TGraphic.


Version 4.4 Generated 2025-11-08 Home