Sign in Join
FPDoc Onlineexperiment

TPicture class

In unit Graphics

Implements a container for TGraphic and descendent classes.

Declaration

pascal
TPicture = class(TPersistent)

Inheritance

  1. TPicture
  2. TPersistent
  3. TObject

Description

TPicture is a TGraphic container. It is used in place of a TGraphic if the graphic can be of any TGraphic class.

It is not a direct descendant of TGraphic, so you will not see TGraphic listed in the Inheritance chart, but it contains a property Graphic, of type TGraphic, so can contain all the properties of a TGraphic.

Defines many private methods for getting and storing various sorts of images such as bitmaps, pixmaps, icons, PNGs etc.

TPicture does not have a defined area used to display the image. This is supplied in the Canvas property in the classes which support BitMap, PixMap, PNG, JPEG, GIF, TIFF or Icon image formats.

LoadFromFile and SaveToFile are polymorphic. For example, if the TPicture is holding an Icon, you can LoadFromFile a bitmap file, whereas if the class is TIcon you could only read .ICO files.

  • LoadFromFile - Reads a picture from disk. The TGraphic class created is determined by the file extension of the file. If the file extension is not recognized an exception is generated.
  • SaveToFile - Writes the picture to disk.
  • LoadFromClipboardFormat - Reads the picture from the handle provided in the given clipboard format. If the format is not supported, an exception is generated.
  • SaveToClipboardFormats - Allocates a global handle and writes the picture in its native clipboard format (CF_BITMAP for bitmaps, CF_METAFILE for metafiles, etc.). Formats will contain the formats written. Returns the number of clipboard items written to the array pointed to by Formats and Datas or would be written if either Formats or Datas are Nil.
  • SupportsClipboardFormat - Returns True if the given clipboard format is supported by LoadFromClipboardFormat.
  • Assign - Copies the contents of the given TPicture. Used in the implementation of TPicture properties.
  • RegisterFileFormat - Register a new TGraphic class for use in LoadFromFile.
  • RegisterClipboardFormat - Registers a new TGraphic class for use in LoadFromClipboardFormat.
  • UnRegisterGraphicClass - Removes all references to the specified TGraphic class and all its descendants from the file format and clipboard format internal lists.
  • Height - The native, unstretched, height of the picture.
  • Width - The native, unstretched, width of the picture.
  • Graphic - The TGraphic object contained by the TPicture
  • Bitmap - Returns a bitmap. If the contents is not already a bitmap, the contents are discarded and a blank bitmap is returned.
  • Pixmap - Returns a pixmap. If the contents is not already a pixmap, the contents are discarded and a blank pixmap is returned.
  • PNG - Returns a png. If the contents is not already a png, the contents are discarded and a blank png ( TPortableNetworkGraphic) is returned.
  • PNM - Returns a pnm. If the contents is not already a pnm, the contents are discarded and a blank pnm ( TPortableAnyMapGraphic) is returned.
  • Jpeg - Returns a jpeg. If the contents is not already a jpeg, the contents are discarded and a blank jpeg ( TJPegImage) is returned.

Properties

BitmappublicBitmap - Returns a bitmap.
IconpublicIcon contained within the picture.
JpegpublicJpeg - returns a JPEG image.
PixmappublicPixmap - Returns a pixmap.
PNGpublicPNG - Returns a png.
PNMpublicPNM - a PortableAnyMapGraphic image.
GraphicpublicGraphic - The TGraphic object contained by the TPicture.
HeightpublicHeight - The native, unstretched, height of the picture.
WidthpublicWidth - The native, unstretched, width of the picture.

Methods

AssignToprotectedAssignTo if Dest is the correct (Graphic) class type, calls Assign for Dest, otherwise calls inherited AssignTo.
ChangedprotectedPerforms actions needed when value(s) in the class instance have been modified.
DefinePropertiesprotectedDefines properties handled during LCL component streaming.
ProgressprotectedMonitors progress of a drawing process.
LoadFromStreamWithClassprotectedLoads values for the Graphic property from a stream using the specified class type.
CreatepublicCreate - constructor for TPicture: performs inherited Create then loads file and clipboard formats.
DestroypublicDestroy - destructor for TPicture: frees graphic then performs inherited Destroy.
ClearpublicClear - removes the Graphic in the class instance.
LoadFromClipboardFormatpublicLoadFromClipboardFormat - Reads the picture from the handle provided in the given clipboard format.
LoadFromClipboardFormatIDpublicReads the picture from a clipboard of type ClipboardType using the format FormatID.
LoadFromFilepublicLoadFromFile - Reads a picture from disk.
LoadFromResourceNamepublicLoads content from the specified resource into the Graphic property.
LoadFromLazarusResourcepublicGets the named resource from a Lazarus Resource (.lrs) file.
LoadFromStreampublicLoads picture data in a supported image format from the specified stream.
LoadFromStreamWithFileExtpublicLoads the picture from a stream containing data for the specified file extension.
SaveToClipboardFormatpublicSaveToClipboardFormats - Allocates a global handle and writes the picture in its native clipboard format.
SaveToFilepublicSaveToFile - Writes the picture to disk.
SaveToStreampublicSaves the graphic to the specified stream.
SaveToStreamWithFileExtpublicSaves graphic image data to a stream using the specified format and file extension.
SupportsClipboardFormatpublicSupportsClipboardFormat - Returns True if the given clipboard format is supported by LoadFromClipboardFormat.
AssignpublicAssign - if the Source is a valid graphic type, copy the relevant details to the current object, otherwise call inherited Assign.
RegisterFileFormatpublicRegisters a new TGraphic class for use in LoadFromFile.
RegisterClipboardFormatpublicRegisters a new TGraphic class for use in LoadFromClipboardFormat.
UnregisterGraphicClasspublicRemoves all references to the specified TGraphic.
FindGraphicClassWithFileExtpublicFinds a graphic class with the named file extension Ext, and raises an exception if not found.

Events

OnChangepublicOnChange - Event handler for any change in the picture.
OnProgresspublicEvent handler signalled to track the progress of operations in the class instance.

Inherited

From TPersistent (5)

FPOAttachObserver FPODetachObserver FPONotifyObservers GetNamePath GetOwner

From TObject (40)

AfterConstruction BeforeDestruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals 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.