trichview.com

trichview.support




Re: How to insert gif


Return to index


Author

Message

Sergey Tkachenko

Posted: 02/12/2003 22:41:04


This method will load gifs without any modifications (except from adding

*.gif in the Filter)

providing that gif class is registered and is associated with the gif

extension. You can do it by calling


RegisterClass(TGifImage);

TPicture.RegisterFileFormat('gif', 'Gif Image', TGifImage);


(since both RX's and Melander's gif classes have name TGifImage, the code is

the same for them).

If you use Delphi version older than 6, some additional code is required

(see "How to use third-party graphic classes in RichView" in the help file)




> { Insert|Picture... ---------------------------------------------------}

> procedure TForm1.mitPictureClick(Sender: TObject);

> var gr: TGraphic;

>     pic: TPicture;

> begin

>   OpenDialog1.Title := 'Inserting Image';

>   {$IFDEF RICHVIEWDEF3}

>   OpenDialog1.Filter :=

'Graphics(*.bmp;*.wmf;*.emf;*.ico;*.jpg)|*.bmp;*.wmf;*.emf;*.ico;*.jpg|All(*

.*)|*.*';

>   {$ELSE}

>   OpenDialog1.Filter :=

'Graphics(*.bmp;*.wmf;*.emf;*.ico)|*.bmp;*.wmf;*.emf;*.ico|All(*.*)|*.*';

>   {$ENDIF}

>   if OpenDialog1.Execute then

>     try

>       pic := TPicture.Create;

>       try

>         pic.LoadFromFile(OpenDialog1.FileName);

>         gr := RV_CreateGraphics(TGraphicClass(pic.Graphic.ClassType));

>         gr.Assign(pic.Graphic);

>       finally

>         pic.Free;

>       end;

>       if gr<>nil then

>         RichViewEdit1.InsertPicture('',gr,rvvaBaseLine);

>     except

>       Application.MessageBox(PChar('Cannot read picture from file

'+OpenDialog1.FileName),

> 'Error',

>         MB_OK or MB_ICONSTOP);

>     end;

> end;

>

> =====================================

> As a new member, I would appreciate hints and help.

>

> Thanks.





Powered by ABC Amber Outlook Express Converter