trichview.com

trichview.support




Re: Saving document with images


Return to index


Author

Message

Sergey Tkachenko

Posted: 03/23/2004 22:12:15


1) RVF

TImage is saved automatically.

Call RegisterClasses([TImage, TGifImage]), and they will be loaded.


2) Saving to HTML and RTF

Saving: use OnSaveComponentToFileEvent


uses CRVData, RVItem, RVFuncs;


procedure TForm3.RichViewEdit1SaveComponentToFile(Sender: TCustomRichView;

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

  var OutStr: String);


  function GetTwipsPerPixel: Double;

  var DC: HDC;

  begin

    DC := CreateCompatibleDC(0);

    if RichViewPixelsPerInch>0 then

      Result := (72*20) / RichViewPixelsPerInch

    else

      Result := (72*20) / GetDeviceCaps(DC, LOGPIXELSY);

    DeleteDC(DC);

  end;


var img: TImage;

    Stream: TStringStream;

begin

  if not (SaveMe is TImage) then

    exit;

  img := TImage(SaveMe);

  case SaveFormat of

    rvsfHTML:

      begin

        OutStr := Sender.SavePicture(rvsfHTML, Path, img.Picture.Graphic);

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

[OutStr,

        img.Width, img.Height]);

      end;

    rvsfRTF:

      begin

        Stream := TStringStream.Create('');

        RVSaveImageToRTF(Stream, GetTwipsPerPixel, img.Picture.Graphic,

          img.Width, img.Height, Sender.RTFOptions);

        OutStr := Stream.DataString;

        Stream.Free;

      end;

  end;

end;


3) Loading from HTML

There is no way to load images from HTML as TImage using RvHtmlImporter.

Only after modifying its source code


4) Loding from RTF

RTF cannot contain Gifs. When saving with the procedure above, they will be

saved as a bitmap or metafile.

Do you want to load all images from RTF as TImage? If yes, I can post an

example.



> My document have TImage with gif (im using TGIFImage) images and others

> TImage with bitmaps and jpegs. How can i save this document to rvf, rtf

and

> html with images?

>

>

> Thanks in advance

>

>





Powered by ABC Amber Outlook Express Converter