trichview.support
Re: Image issues with TRichViewEdit and saving as HTML |
Author |
Message |
Sergey Tkachenko |
Posted: 11/17/2003 19:57:27 Add this code to event OnHTMLSaveImage. (this code assumes that prefix for image file names is 'img', and rvsoOverrideImages is specified in Options for saving. If not, change the first and the last parameters in call of RVData.GetNextFileName procedure TForm3.RichViewEdit1HTMLSaveImage(Sender: TCustomRichView; RVData: TCustomRVData; ItemNo: Integer; const Path: String; BackgroundColor: TColor; var Location: String; var DoDefault: Boolean); var gr: TGraphic; bmp: TBitmap; jpg: TJpegImage; s: String; AVAlign: TRVVAlign; ATag: Integer; Width, Height: Integer; begin if (ItemNo>=0) and ((RVData.GetItemStyle(ItemNo)=rvsPicture) or (RVData.GetItemStyle(ItemNo)=rvsHotPicture)) then begin RVData.GetPictureInfo(ItemNo, s, gr, AVAlign, ATag); RVData.GetItemExtraIntProperty(ItemNo, rvepImageWidth, Width); RVData.GetItemExtraIntProperty(ItemNo, rvepImageHeight, Height); if Width=0 then Width := gr.Width; if Height=0 then Height := gr.Height; bmp := TBitmap.Create; jpg := TJpegImage.Create; try bmp.PixelFormat := pf32bit; bmp.Width := Width; bmp.Height := Height; bmp.Canvas.StretchDraw(Rect(0,0,Width,Height), gr); jpg.Assign(bmp); Location := RVData.GetNextFileName('img', Path, '.jpg', Sender.imgSaveNo, True); jpg.SaveToFile(Location); Location := ExtractRelativePath(Path, Location); DoDefault := False; finally bmp.Free; jpg.Free; end; end; end; |
Powered by ABC Amber Outlook Express Converter