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

# TGraphic

[Properties (by Name)] [Methods (by Name)] [Events (by Name)]

TGraphic - Base class for dealing with Graphic images

## Declaration

Source position: graphics.pp line 758

`type TGraphic = class(TPersistent)`
`protected`
`procedure Changed(); virtual;` |  | Changed - software emulation of a call to the OnChange event
`function Equals(); virtual;` |  | Equals - returns True if the current Graphic is the same as the specified Graphic
`procedure DefineProperties(); override;` |  | DefineProperties finds out whether the object really is a binary (graphic)
`procedure Draw(); virtual; abstract;` |  | Method to Draw the Graphic on the specified Canvas, in the specified Rectangle
`function GetEmpty; virtual; abstract;` |  | GetEmpty - returns True if the Graphic is empty
`function GetHeight; virtual; abstract;` |  | GetHeight - returns the height of the Graphic
`function GetMimeType; virtual;` |  | GetMimeType - returns the MIME type of the Graphic
`function GetPalette; virtual;` |  | GetPalette - returns a Handle for the Palette
`function GetTransparent; virtual; abstract;` |  | GetTransparent - returns True if the graphic is transparent
`function GetWidth; virtual; abstract;` |  | GetWidth - returns the width of the Graphic
`procedure Progress();` |  | Monitor the Progress of the drawing
`procedure ReadData(); virtual;` |  | ReadData - reads data for the Graphic from a stream
`procedure SetHeight(); virtual; abstract;` |  | SetHeight - defines the height for the Graphic
`procedure SetPalette(); virtual;` |  | SetPalette - deefines the Palette Handle to be used
`procedure SetTransparent(); virtual; abstract;` |  | SetTransparent - defines whether the graphic is to be transparent
`procedure SetWidth(); virtual; abstract;` |  | SetWidth - defines the width for the Graphic
`procedure SetModified();` |  | SetModified - defines whether the graphic has been modified
`procedure WriteData(); virtual;` |  | WriteData - writes Graphic data to a stream
`public`
`procedure Assign(); override;` |  | Assign - checks if there really is a source to assign (if not, calls Clear), then calls inherited method
`constructor Create; virtual;` |  | Create - constructor for TGraphic: calls inherited Create
`procedure Clear; virtual;` |  | Clear the resources used by the Graphic, leaving a blank Graphic
`function LazarusResourceTypeValid(); virtual;` |  | Check that the Resource specified for reading or writing is a valid type - result True if it is
`procedure LoadFromFile(); virtual;` |  | LoadFromFile - Read the graphic from the file system.
`procedure LoadFromStream(); virtual; abstract;` |  | LoadFromStream - reads graphic data from a stream (e.g. TBlobStream )
`procedure LoadFromMimeStream(); virtual;` |  | LoadFromMimeStream - reads graphic data from a MIME stream
`procedure LoadFromLazarusResource(); virtual;` |  | Load the graphic data from a Lazarus Resource (eg a *.lrs file)
`procedure LoadFromResourceName(); virtual;` |  | Load the graphic data from a resource identified by the name ResName with the Handle 'Instance'
`procedure LoadFromResourceID(); virtual;` |  | Load graphic data from a resource identified by the integer identifier ResID
`procedure LoadFromClipboardFormat(); virtual;` |  | LoadFromClipboardFormat - Replace the current image with the contents of the clipboard
`procedure LoadFromClipboardFormatID(); virtual;` |  | Load the data from the clipboard using the format type specified by ClipboardType and the format identifier FormatID
`procedure SaveToFile(); virtual;` |  | SaveToFile - Writes the graphic to disk in the file provided.
`procedure SaveToStream(); virtual; abstract;` |  | SaveToStream - write graphic data to a stream
`procedure SaveToClipboardFormat(); virtual;` |  | SaveToClipboardFormats - Converts the image to a clipboard format
`procedure SaveToClipboardFormatID(); virtual;` |  | Saves the data to a clipboard of Type ClipboardType using the format FormatID
`procedure GetSupportedSourceMimeTypes(); virtual;` |  | Gets a list of the MIME types that are supported
`function GetResourceType; virtual;` |  | GetResourceType - returns the type of a resource to be used in the graphic
`public`
`class function GetFileExtensions; virtual;` |  | GetFileExtensions - returns a list of the file extensions available
`class function IsStreamFormatSupported(); virtual;`
`public`
`property Empty: Boolean; [r]` |  | Is this an empty (blank) graphic?
`property Height: Integer; [rw]` |  | Height - The native, unstretched, height of the graphic.
`property Modified: Boolean; [rw]` |  | Has the graphic been modified?
`property MimeType: String; [r]` |  | MimeType - the MIME type of the graphic
`property OnChange: TNotifyEvent; [rw]` |  | Event handler for any change in the data
`property OnProgress: TProgressEvent; [rw]` |  | Event handler for monitoring progress of the graphic
`property Palette: HPALETTE; [rw]` |  | Palette - Color palette of image
`property PaletteModified: Boolean; [rw]` |  | Has the palette of colours been modified?
`property Transparent: Boolean; [rw]` |  | Transparent - Some parts of the image are not opaque. ie the background can be seen through
`property Width: Integer; [rw]` |  | Width - The native, unstretched, width of the graphic.
`end;`

## Inheritance

`TGraphic` |  | TGraphic - Base class for dealing with Graphic images
`TPersistent`
`TObject`

## Description

The TGraphic class is an abstract base class for dealing with graphic images such as bitmaps, pixmaps, icons, and other image formats. It does not contain an actual area for displaying the image; this is provided by the descendant classes eg BitMap, Icon etc which have a Canvas element defined
LoadFromFile - Read the graphic from the file system. The old contents of the graphic are lost. If the file is not of the right format, an exception will be generated.
SaveToFile - Writes the graphic to disk in the file provided.
LoadFromStream - Like LoadFromFile except source is a stream (e.g. TBlobStream ).
SaveToStream - stream analogue of SaveToFile .
LoadFromClipboardFormat - Replaces the current image with the data provided. If the TGraphic does not support that format it will generate an exception.
SaveToClipboardFormats - Converts the image to a clipboard format. If the image does not support being translated into a clipboard format it will generate an exception.
Height - The native, unstretched, height of the graphic.
Palette - Color palette of image. Zero if graphic doesn't need/use palettes.
Transparent - Some parts of the image are not opaque, ie the background can be seen through.
Width - The native, unstretched, width of the graphic.
OnChange - Called whenever the graphic changes
PaletteModified - Indicates in OnChange whether color palette has changed. Stays true until whoever is responsible for realizing this new palette (ex: TImage) sets it to False.
OnProgress - Generic progress indicator event. Propagates out to TPicture and TImage OnProgress events.
As many of the methods and properties are virtual and/or abstract, it is the responsibility of the application programmer to supply suitable methods when implementing any descendant classes

The latest version of this document can be found at lazarus-ccr.sourceforge.net.