rvico TRichView Reference | Item Types

Pictures

Top  Previous  Next

Pictures

Picture item displays a picture stored in TGraphic object.

Delphi has the following standard graphic classes:

TBitmap (stores bitmap (*.bmp), probably with transparency);
TMetafile (stores 32-bit (*.emf) or 16-bit (*.wmf) metafile);
TIcon (stores icon; this class does not work with icons having more than 16 colors properly);
TJpegImage (D3+; stores Jpegs (*.jpg));
TGifImage (D2007+, stores Gifs (*.gif)).

In addition, you can use third-party graphic classes.

Style of this item type: rvsPicture (-3)

For hypertext pictures, see hot-pictures item type.

Additional Properties

This item type has the following specific extra integer properties:

rvepImageWidth, rvepImageHeight stretch the image;
rvepTransparent, rvepTransparentMode, rvepTransparentColor define transparency in bitmap;
rvepAnimationInterval interval for bitmap animations;
rvepMinHeightOnPage allows printing this image on multiple pages (cannot be applied to metafiles);
rvepSpacing spacing around the picture;
rvepResizable allows resizing (ignored for TIcon).

This item type has the following specific extra string properties:

rvespAlt text representation of the image, saved in HTML as <IMG alt> attribute;
rvespImageFileName this property can be saved in HTML file as image location.

This item type has the following properties affecting vertical position:

VAlign;
extra properties: rvepVShift, rvepVShiftAbs.

Resizing

In editor, pictures can be resized with the mouse (except for TIcon). You can forbid mouse resizing by including rvoNoImageResize in EditorOptions. You can forbid resizing for the specific image by assigning 0 to rvepResizable extra integer property.

Resizing with mouse does not modify the image itself, it changes rvepImageWidth and rvepImageHeight.

OnItemResize event occurs after resizing.

Methods of TCustomRichView

The following viewer-style methods add item of this type to the end of the document:

AddPictureEx,
AddPictureExTag

The following viewer-style method changes the main properties of item of this type:

SetPictureInfo

The following method returns main properties of the given item of this type:

GetPictureInfo

Methods of TCustomRichViewEdit

The following editor-style method inserts item of this type in the position of caret:

InsertPicture

The following editor-style methods modify main properties of the item of this type:

SetCurrentPictureInfo,
SetPictureInfoEd

The following method returns main properties of the item of this type at the position of caret:

GetCurrentPictureInfo

Memory Usage

RichView owns this graphic object, and it will destroy it when clearing document. Do not free memory for graphic object inserted in RichView yourself. Do not insert the same graphic object twice.

Saving and Loading

RichView Format (RVF)

In order to load these items from RVF, you need to register a class of the graphics. RichView does it automatically for the standard item classes. But if you use third-party graphic classes, register them.

For example:

Delphi: RegisterClass(TGifImage);
C++Builder: RegisterClass(__classid(TGifImage));

If rvfoSavePicturesBody is excluded from RVFOptions, graphic data is not saved in RVF. When loading such RVF files, OnRVFPictureNeeded event occurs. You can use this feature to store images in database or files.

Export to HTML

By default, all pictures are saved as jpegs (or as bitmaps). If you want to save pictures of some graphic class without conversion, call RV_RegisterHTMLGraphicFormat.

For example:

Delphi: RV_RegisterHTMLGraphicFormat(TGifImage);
C++Builder: RV_RegisterHTMLGraphicFormat(__classid(TGifImage));

If you want to save pictures in another format, use OnHTMLSaveImage or OnSaveImage2 events.

RTF export

RTFOptions contain options for saving pictures in RTF. Pictures are embedded in RTF, external image files are not created.

Bitmaps are stored as bitmaps. 32-bit metafiles (EMF) are stored as 32-bit or 16-bit (WMF) metafiles.

PNG images are stored as PNG images, if PNG class is specified.

All other graphic formats are stored as bitmaps, WMF or PNG (except for Jpegs which can be stored as Jpegs).

RTF Import

You can set RTFReadProperties.IgnorePictures to True, and pictures in RTF will not be added in RichView.

RTF can have embedded images and external images (in separate files). In order to load external images, a proper graphic class must be associated with the file extension.

Delphi does it for standard graphic classes automatically, but for some third-party classes you need to do it yourself.

For example:

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

Read more information in the topic about third-party graphic classes.

See Also...

Working in 256-color display mode;
Animation.


RichView © Sergey Tkachenko