|Top Previous Next|
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));
▪TPngImage (D2009+, stores Png (*.png));
▪TWicImage (D2010+, by default used for Tiff (*.tif) images, but can be used for other graphic formats).
In addition, you can use third-party graphic classes.
Style of this item type: rvsPicture (-3)
For hypertext pictures, see hot-pictures item type.
Methods of TCustomRichView
The following viewer-style methods add item of this type to the end of the document:
The following viewer-style method changes the main properties of item of this type:
The following method returns main properties of the given item of this type:
Methods of TCustomRichViewEdit
The following editor-style method inserts item of this type in the position of caret:
The following editor-style methods modify main properties of the item of this type:
The following method returns main properties of the item of this type at the position of caret:
This item type has the following integer properties related to size:
▪rvepImageWidth, rvepImageHeight stretch the image.
Layout and appearance
This item type has the following integer properties related to layout and appearance:
▪rvepSpacing – padding (spacing between the picture and its border; if a background color is specified, this area is colored);
▪rvepColor – background color;
▪rvepBorderWidth, rvepBorderColor – width and color of a border;
▪rvepOuterHSpacing, rvepOuterVSpacing – horizontal and vertical spacing around the border.
By default, TRichView frees a graphic object when this item is destroyed, or when a new graphic object is assigned.
However, if rvepShared integer property is nozero, TRichView does not free it.
This item type has the following properties affecting vertical position:
▪extra integer properties: rvepVShift, rvepVShiftAbs.
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 integer property.
Resizing with mouse does not modify the image itself, it changes rvepImageWidth and rvepImageHeight.
OnItemResize event occurs after resizing.
This item type has the following specific integer properties:
▪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);
▪rvepNoHTMLImageSize – if nonzero, <IMG width> and <IMG height> are not saved in HTML for this image.
This item type has the following specific 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.
Saving and Loading
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.
Classes of the most of standard graphic formats are automatically registered by TRichView, see the topic about RVGraphicHandler.
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. If you want to save pictures of some graphic class without conversion, call RVGraphicHandler.RegisterHTMLGraphicFormat.
The standard PNG and GIF formats may be automatically registered by TRichView, see the topic about RVGraphicHandler.
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 (see RVGraphicHandler.RegisterPngGraphic).
All other graphic formats are stored as bitmaps, WMF or PNG (except for Jpegs which can be stored as Jpegs).
All graphic formats are stored as they are, except for:
▪bitmaps (they are saved as PNG, if PNG graphic class is defined, see RVGraphicHandler.RegisterPngGraphic;
▪icons (they are saved as PNG in Delphi 2009+ using TPngImage class)
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.
Read more information in the topic about third-party graphic classes.
TRichView © trichview.com