Occurs when TRichView saves item containing image to HTML file or stream. This event allows to modify saving procedure for all (or some) images.
procedure (Sender: TCustomRichView; RVData: TCustomRVData;
ItemNo: Integer; const Path: TRVUnicodeString;
BackgroundColor: TColor; var Location: String;
var DoDefault: Boolean) of object;
property OnHTMLSaveImage: TRVHTMLSaveImageEvent;
(introduced in version 1.4; changed in version 16)
This event is called for the following item types:
▪list markers (paragraph bullets) with images,
There is more easy-to-use event: OnSaveImage2.
Images are saved in separate files as Jpegs (or as bitmaps for Delphi2, or if RVDONOTUSEJPEGIMAGE is defined) and have names composed as ImagesPrefix + Number + '.jpg', where
▪Number – some number making this file name unique (image files can override existing ones or not, depending on parameters of SaveHTML/SaveHTMLEx). Bullets and hotspots items having the same image list, image index and background color are saved in the same file (the same is for list markers).
Transparent color of bullets, hotspots and transparent image formats (TIcon, TMetafile, gifs) is replaced with background color (which can be color of component (TRichView.Color/TRVStyle.Color), color of cell (TRVTableCellData.Color) or color of paragraph background (TRVBackroundRect.Color).
ItemNo – index of this item inside RVData. If this event is called for background image (document or cell), ItemNo=-1.
BackgroundColor – color of background below the item (can be ignored, if you can preserve transparency of image)
Location – if rvsoUseItemImageFileNames is included in the Options parameter of SaveHTML/SaveHTMLEx, this is a path to the image defined in the rvespImageFileName item property, relative to Path. Otherwise, initial value of this parameter is empty.
Location – set this parameter to file name of image where you saved it. This string will be inserted in HTML file.
DoDefault – set to False if you saved this item as image yourself, to disallow default saving. If DoDefault is True, then after calling this event:
▪if rvsoUseItemImageFileNames is included in the Options parameter of SaveHTML/SaveHTMLEx and value of rvespImageFileName item property is not empty, this value is written in HTML (relative to Path); otherwise
▪OnSaveImage2 is called (if its handler is assigned); if it is not assigned or OnSaveImage2's DoDefault parameter is True, the default image saving procedure is called.
Inside this event you can use:
▪Sender.imgSaveNo – value which was used as Number for file name for the previously saved image;
▪RVData.GetNextFileName – function returning image file name with the given image prefix and extension:
function GetNextFileName(const ImagesPrefix, Path, Ext: TRVUnicodeString;
var imgSaveNo: Integer; OverrideFiles: Boolean): TRVUnicodeString;
Path – path for the image (for example, you can use Path parameter of this event);
Ext – file extension, for example '.jpg' (you can use GraphicExtension(TGraphicClass(Graphic.ClassType)));
imgSaveNo – this function will use this value incremented one or several times to compose a name of image; returns the incremented value;
OverrideFiles – if set to False, this function will check existing files and returns an unique file name (by incrementing imgSaveNo several times)
Return value: full file name of the image. You can use it to save image and assign it to Location parameter of the event (this file name includes path, use ExtractFileName or ExtractRelativePath).
Alternatively, you can use SavePicture.
See also events: