|
TCustomRichView.OnHTMLSaveImage |
Top Previous Next |
|
Occurs when TRichView saves item containing image to HTML file or stream. This event allows to modify saving procedure for all (or some) images. type TRVHTMLSaveImageEvent = procedure (Sender: TCustomRichView; RVData: TCustomRVData; ItemNo: Integer; const Path: String; BackgroundColor: TColor; var Location: String; var DoDefault: Boolean) of object;
property OnHTMLSaveImage: TRVHTMLSaveImageEvent; (introduced in version 1.4) This event is called for the following item types:
There is more easy-to-use event: OnSaveImage2. By default: 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
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). You can define formats that must not be converted to Jpeg. Input Parameters RVData – document containing item that is being saved to image; it can be Sender.RVData, table cell, or RVData of cell inplace-editor. ItemNo – index of this item inside RVData. If this event is called for background image (document or cell), ItemNo=-1. Path – destination directory of HTML file (or Path parameter of SaveHTMLToStream/SaveHTMLToStreamEx). 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. Output Parameters 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:
Inside this event you can use:
function GetNextFileName(const ImagesPrefix, Path, Ext: String; var imgSaveNo: Integer; OverrideFiles: Boolean): String; where ImagesPrefix – the first part of image file name (for example, you can set it to ImagesPrefix parameter of SaveHTML/SaveHTMLEx); 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: See also |