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

# TGraphic.LoadFromFile

Reads data for the graphic from a file.

## Declaration

Source position: graphics.pp line 833

`public procedure TGraphic.LoadFromFile(`
`const Filename: string`
`); virtual;`

## Arguments

`Filename` |  | The name of the file containing the graphic data.

## Description

LoadFromFile reads data for the graphic from the local file system. FileName contains the name of the file on the local file system with data for the graphic, and may contain UTF-8-encoded characters in the file name.

LoadFromFile creates a temporary TFileStreamUTF8 instance that is used to read the contents of the file by calling LoadFromStream. Any existing image data in the class instance is discarded. An Exception can be raised in LoadFromStream if Filename does not contain a valid file name.

## Errors

Raises an Exception if an invalid file name is passed to the method.

## See also

TGraphic.LoadFromStream |  | Reads graphic data from a stream.
TGraphic.LoadFromMimeStream |  | Loads the from the specified stream for the given MIME type.
TGraphic.LoadFromResourceName |  | Loads a resource with the specified name from the given handle.
TGraphic.LoadFromLazarusResource |  | Load the graphic data from a Lazarus Resource (.lrs) file.
TGraphic.LoadFromClipboardFormat |  | LoadFromClipboardFormat - Replace the current image with the contents of the clipboard.
TGraphic.SaveToFile |  | Writes graphic data to the specified file name.