TCustomIcon.ReadStream procedure
Reads the content for the icon from the specified stream.
Declaration
procedure ReadStream(AStream: TMemoryStream; ASize: LongInt); overrideArguments
AStream | Stream instance with the image content read in the method. |
ASize | Number of bytes expected for the icon data. |
Description
ReadStream is an overridden procedure used to read the content for
the icon from the stream specified in
AStream. ReadStream
implements the abstract virtual method defined in the ancestor class.
ReadStream verifies that AStream contains an icon image by checking for
header value(s) that are valid for .ICO data. If the header values are not
found, an EInvalidGraphic exception is raised.
For icon data, the icon directory must be read from the stream. The header contains the number of icon directory entries included in the stream. The icon directory entries are read from AStream, and include values for each icon image that includes:
- HotSpotX
- HotSpotY
- BytesInRes
- ImageOffset
ReadStream positions the stream, and reads image data for the each of the
icon directory entries. It handles both DIB Bitmap and PNG (used in Windows
Vista) image data for the icon images. An FCL-compatible image reader is
created as required for the image type, and a TLazIntfImage
instance is used to capture the raw image data from the stream. Images read
from the stream are added to the internal list of images in the
TSharedIcon member for the class instance.
ReadStream calls CheckRequestedSize to use the Width
and/or Height specified in the class instance.
GetBestIndexForSize is called to determine the value in
Current with the requested image size.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
