trichview.com

trichview.support




Re: OnsavecomponenttoFile event


Return to index


Author

Message

Sergey Tkachenko

Posted: 02/21/2003 22:22:29


This procedure saves images of inserted controls as gifs in HTML.

It will work both with RX and Ander's TGifImage.


uses CtrlImg;


procedure TForm1.RichViewEdit1SaveComponentToFile(Sender: TCustomRichView;

  Path: String; SaveMe: TPersistent; SaveFormat: TRVSaveFormat;

  var OutStr: String);

var FileName: String;

    gif: TGifImage;

    bmp: TBitmap;

begin

  case SaveFormat of

   rvsfHTML:

       begin

         FileName := Sender.RVData.GetNextFileName( 'img', Path, '.gif',

Sender.imgSaveNo, True);

         gif := TGIFImage.Create;

         try

           gif.ColorReduction := rmQuantize; // remove it if you use RXLib's

TGifImage;

           bmp := DrawControl(TControl(SaveMe));

           gif.Assign(bmp);

           bmp.Free;

           gif.SaveToFile(FileName);

         finally

           gif.Free;

         end;

         FileName := ExtractRelativePath(Path, FileName);

         OutStr := Format('<IMG src="%s" width=%d height=%d>',

           [FileName, TControl(SaveMe).Width, TControl(SaveMe).Height]);

       end;

   end;

end;





Powered by ABC Amber Outlook Express Converter