rvico TRichView Reference | How to...

...use third-party graphic classes with RichView

Top  Previous  Next

Using third party graphic classes

You can use graphic classes created by third party developers.

These classes can be used just like standard classes (TBitmap, TIcon, TMetafile, TJpegImage).

You can add picture in a document using AddPictureEx or InsertPicture.

Example:

gif: TGifImage;

...

gif := TGifImage.Create;

gif.LoadFromFile('demo.gif');

editor.InsertPicture('Demo', gif, rvvaBaseLine);

For example, you can use free graphic classes:

Anders Melander's TGifImage www.torry.net/vcl/graphics/gif/gifimage.exe (update for Delphi 6 and newer: www.trichview.com/resources/thirdparty/gifimage.zip);

TJvGifImage from JEDI's JVCL http://jvcl.sourceforge.net;

Gustavo Huffenbacher Daud's TPngObject www.trichview.com/resources/thirdparty/pngimage.zip.

Starting from Delphi 2007, an advanced version of Anders Melander's TGifImage is included in VCL, so TGifImage becomes a standard graphic class.

Starting from Delphi 2009, TPngImage is included in VCL.

Gif animation

To support animation, assign TCustomRichView.AnimationMode = rvaniOnFormat.

The following units must be included in your projects:

RVGifAnimate for Anders Melander's TGifImage;

RVJvGifAnimate for TJvGifImage from JEDI's JVCL;

RVGifAnimate2007 for standard Delphi TGifImage (in Delphi 2007 or newer).

See also: animation in TRichView

Controlling automatic insertion of graphics when importing RTF

Sometimes images are inserted automatically (for example, when importing images referred from RTF).

Question: What graphic classes does TRichView use for loading non-standard graphic formats (such as GIF or PNG)?

Answer: RichView uses the graphic class which is registered for the given file extension.

If a third party creator has not associated his graphic class with the extension, you can do it yourself with TPicture.RegisterFileFormat:

TPicture.RegisterFileFormat('gif','Gif Image',TGifImage);

This registration is especially necessary if you define this graphic format as HTML graphic format.

Workaround for Delphi bug in constructors of graphic classes (Delphi 5 or older)

If you use Delphi 5/C++Builder 5 or older, use RVGraphicHandler.CreateGraphic (defined in RVFuncs unit) instead of direct call of graphic class constructor.

It is not necessary if you use Delphi 6/C++Builder 6 or newer.

Exporting graphics in HTML

By default, all images are converted to JPEGs. This is obviously undesirable for formats like GIF and PNG.

You can specify which graphic classes must not be converted.

Use RVGraphicHandler.RegisterHTMLGraphicFormat procedure, for example:

uses RVGrHandler;

...

// call this before the first html export

RVGraphicHandler.RegisterHTMLGraphicFormat(TMyGifImage);

This registration affects only images of the given format. Other formats will be converted to JPEGs.

TRichView registers the following classes as HTML graphic formats automatically:

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.

Specifying PNG class

Specify graphic class for PNG images using Use RVGraphicHandler.RegisterPngGraphic, for example:

uses RVFuncs;

...

RVGraphicHandler.RegisterPngGraphic(TPngObject). 

It allows loading PNG images from RTF files and saving PNG images to RTF and DocX files without converting to bitmaps or metafiles.

In Delphi 2009+, TRichView automatically registers the standard TPngImage as a PNG class.

Specifying JPEG class

Specify graphic class for Jpeg images using Use RVGraphicHandler.RegisterJpegGraphic, for example:

uses RVFuncs;

...

RVGraphicHandler.RegisterJpegGraphic(TMyJpegImage). 

If you do not call this method, TRichView uses TJPEGImage.

This class is used when loading JPEG images embedded in RTF.

In Delphi 2009+, TRichView automatically registers the standard TPngImage as a PNG class.

Using DevExpress graphic classes

If you uncomment RVUSEDXPNGIMAGE in RV_Defs.inc, TRichView supports DevExpress classes:

TcxPngImage for Png

TdxSmartImage for Bitmap, Jpeg, Tiff, Gif images.

TcxPngImage becomes a default Png class for TRichView, but TdxSmartImage does not become a default Jpeg class, unless you call RVGraphicHandler.RegisterJpegGraphic explicitly.


TRichView © trichview.com