Sign in Join
FPDoc Onlineexperiment

TGraphic class

In unit Graphics

Abstract base class used for images in supported image formats.

Declaration

pascal
TGraphic = class(TPersistent)

Inheritance

  1. TGraphic
  2. TPersistent
  3. TObject

Descends from it: TRasterImage

Description

The TGraphic class is an abstract base class for graphic images in image formats supported in the LCL. TGraphic establishes an API that is used in the LCL to read and write image data using a file, stream, resource, or the clipboard. Many of its methods are defined as virtual and/or abstract, and must be implemented (or re-implemented) in descendent classes to provide support for specific image formats.

Methods defined in TGraphic include:

  • LoadFromFile
  • LoadFromStream
  • LoadFromMimeStream
  • LoadFromLazarusResource
  • LoadFromResourceName
  • LoadFromResourceID
  • LoadFromClipboardFormat
  • LoadFromClipboardFormatID
  • SaveToFile
  • SaveToStream
  • SaveToClipboardFormat
  • SaveToClipboardFormatID
  • GetSupportedSourceMimeTypes
  • GetResourceType
  • GetFileExtensions
  • IsStreamFormatSupported

TGraphic does not contain a mechanism for displaying or rendering an image. This capability is implemented in descendent classes which provide a TCanvas suitable for the image data, such as: TRasterImage, TBitmap, TIcon, TPixmap, TJPegImage, TGifImage, et. al.

Properties common to most image formats are defined in the class, and include:

  • Height
  • Width
  • Modified
  • Empty
  • MimeType
  • Palette
  • PaletteModified
  • Transparent

Event handlers are provided for change and progress notifications, including:

  • OnChange
  • OnProgress

TGraphic is the type used to implement the Graphic property in TPicture, and passed as an argument to methods in TCanvas.

See also

Properties

EmptypublicIndicates if the graphic is empty (contains no data).
HeightpublicThe native, unstretched height for the graphic.
ModifiedpublicIndicates if the graphic data in the class instance has been modified.
MimeTypepublicMimeType - the MIME type of the graphic.
PalettepublicHandle to the color palette used in image data.
PaletteModifiedpublicIndicates whether the palette of colors been modified.
TransparentpublicIndicates whether some parts of the image are not opaque.
WidthpublicWidth - The native, unstretched, width of the graphic.

Methods

ChangedprotectedPerforms action needed when the image data has changed.
EqualsprotectedDetermines if the specified class instance is the same as the current class instance.
DefinePropertiesprotectedDefineProperties finds out whether the object really is a binary (graphic).
DrawprotectedMethod used to draw the Graphic on the specified Canvas, in the specified Rectangle.
GetEmptyprotectedGets the value for the Empty property.
GetHeightprotectedGets the value for the Height property.
GetMimeTypeprotectedGets the value for the MimeType property.
GetPaletteprotectedGets the value for the Palette property.
GetTransparentprotectedGets the value for the Transparent property.
GetWidthprotectedGets the value for the Width property.
ProgressprotectedMonitor the Progress of the drawing.
ReadDataprotectedReadData - reads data for the Graphic from a stream.
SetHeightprotectedSets the value for the Height Property.
SetPaletteprotectedSets the value for the Palette property.
SetTransparentprotectedSets the value for the Transparent property.
SetWidthprotectedSets the value for the Width property.
SetModifiedprotectedSets the value for the Modified property.
WriteDataprotectedWrites the data for the Graphic to a stream.
AssignpublicImplements object persistence for the TGraphic type.
CreatepublicConstructor for the class instance.
ClearpublicClear has an empty implementation in TGraphic.
LazarusResourceTypeValidpublicDetermines if the specified resource type is valid for the image format.
LoadFromFilepublicReads data for the graphic from a file.
LoadFromStreampublicReads graphic data from a stream.
LoadFromMimeStreampublicLoads the from the specified stream for the given MIME type.
LoadFromLazarusResourcepublicLoad the graphic data from a Lazarus Resource (.lrs) file.
LoadFromResourceNamepublicLoads a resource with the specified name from the given handle.
LoadFromResourceIDpublicLoads graphic data from a resource identified by the integer identifier ResID.
LoadFromClipboardFormatpublicLoadFromClipboardFormat - Replace the current image with the contents of the clipboard.
LoadFromClipboardFormatIDpublicLoad the data from the clipboard using the format type specified by ClipboardType and the format identifier FormatID.
SaveToFilepublicWrites graphic data to the specified file name.
SaveToStreampublicSaveToStream - write graphic data to a stream.
SaveToClipboardFormatpublicSaveToClipboardFormats - Converts the image to a clipboard format.
SaveToClipboardFormatIDpublicSaves the data to a clipboard of Type ClipboardType using the format FormatID.
GetSupportedSourceMimeTypespublicGets a list of supported MIME types for data used in the graphic.
GetResourceTypepublicGets the Integer Resource Type for the class instance.
GetFileExtensionspublicReturns a list of the file extensions available.
IsStreamFormatSupportedpublicIndicates whether the specified stream type is supported in the class.

Events

OnChangepublicEvent handler signalled when data in the class instance is changed.
OnProgresspublicEvent handler signalled to track the progress of operations in the class instance.

Inherited

From TPersistent (7)

AssignTo Destroy FPOAttachObserver FPODetachObserver FPONotifyObservers GetNamePath GetOwner

From TObject (39)

AfterConstruction BeforeDestruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName newinstance QualifiedClassName SafeCallException StringMessageTable SystemHasExtendedRTTI ToString UnitName

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.