|Top Previous Next|
This class provides an abstraction layer for managing graphic in TRichView components. It is designed to make TRichView components independent of specific graphic classes.
TRVGraphicHandler = class;
(introduced in version 15)
A single variable of this class is created: RVGraphicHandler. You can call methods of the object returned in this variable.
Additionally, you can create a class inherited from TRVGraphicHandler and assign it to this variable (however, this possibility is not discussed in this help file).
A complete description of all methods of this class is beyond the scope of this help file.
The following methods are useful:
rvgtGIF, rvgtTIFF, rvgtAnyMap, rvgtOther);
function CreateGraphicByType(GraphicType: TRVGraphicType): TGraphic;
Choosing default graphic classes
RegisterPngGraphic registers a PNG graphic class for using in TRichView. Call this method one time when the application starts (for example, in the initialization section of the main form's unit). If PNG class is registered, TRichView controls can save and load PNG images in RTF and and save in DocX files. Optionally, bitmaps can be saved as PNG in RTF too, see TCustomRichView.RTFOptions property (rvrtfPNGInsteadOfBitmap).
By default, in Delphi 2009+, TRichView registers a standard TPngImage as PNG graphic format, so, unless you want to use another class for PNG images, this method is necessary only for Delphi 2007 or older. For example, you can use Gustavo Huffenbacher Daud's TPngObject: download file (free PNG graphic class). In Lazarus, TPortableNetworkGraphic is registered automatically.
RegisterJpegGraphic registers a JPEG graphic class for using in TRichView. If this method is not called, TRichView uses TJPEGImage. This class is used when loading Jpeg images embedded in RTF.
There is an universal method allowing to define graphic classes for the specified graphic type: SetDefaultGraphicClass.
By default, the classes are:
▪metafiles: TMetafile (for Delphi), undefined for Lazarus
▪png: TPngImage (for Delphi 2009+), TPortableNetworkGraphic (for Lazarus), undefined otherwise
▪gif: TGifImage (for Delphi 2007+, if RVGifAnimate2007 is included in the project; for previous versions of Delphi, if RVGifAnimate is included in the project; undefined otherwise
▪tiff: TWicImage (for Delphi 2010+), TTiffImage (for Lazarus), undefined otherwise
▪anymap: TPortableAnyMapGraphic (for Lazarus), undefined otherwise
RegisterHTMLGraphicFormat allows to define HTML graphic formats. Call this method one time when the application starts (for example, in the initialization section of the main form's unit). Images of these formats are saved in HTML as they are, without conversion to Jpegs. It's not necessary to call it for TJpegImage. These formats must have file extension associated, see TPicture.RegisterFileFormat. TRichView registers the following classes as HTML graphic formats:
▪standard TPngImage (for Delphi 2009+);
▪standard TGifImage (for Delphi 2007+), if you include RVGifAnimate2007 unit in your project;
▪Anders Melander's TGifImage, if you include RVGifAnimate unit in your project;
▪TJvGifImage from JEDI's JVCL, if you include RVJvGifAnimate unit in your project.
CreateGraphic creates a graphic of this specified class. For Delphi/C++Builder 6 or newer, this method is equivalent to calling GraphicClass.Create. For older version of Delphi, this method contains a workaround for TGraphic bug.
CreateGraphicByType creates a graphic of the specified type, see "Choosing default graphic classes" above.
LoadFromFile creates a graphic object, loads the file FileName in it, and returns this graphic. A TGraphic class of a created object is determined by the file extension of the file. If the file extension is not recognized, or loading failed, the method returns nil.
LoadFromStream creates a graphic object, loads the stream content in it, and returns this graphic. A graphic format is recognized by content. If this procedure cannot recognize a graphic format, or no graphic class is defined for this graphic type,
TRichView © trichview.com