Insert gif is ok,but cannot load the stream

General TRichView support forum. Please post your questions here
Post Reply
greatsea
Posts: 14
Joined: Sat Nov 05, 2011 5:54 pm

Insert gif is ok,but cannot load the stream

Post by greatsea »

dear sir,now I do a demo about insert gif ,save to stream,and load from stream.(the bmp,jpg,png,etc is all ok,only the gif is not ok)
1.down http://www.trichview.com/resources/thir ... fimage.zip
2.Use RVGifAnimate,GifImage(and set RichView.AnimationMode = rvaniOnFormat).
3.
initialization
TPicture.RegisterFileFormat('gif','Gif Image',TGifImage);
(It looks like not importent)
4.insert the gif file:
pic := TPicture.Create;
try
pic.LoadFromFile(OpenDialog1.FileName);
gr := RV_CreateGraphics(TGraphicClass(pic.Graphic.ClassType));
gr.Assign(pic.Graphic);
rve.TopLevelEditor.BeginUndoGroup(rvutInsert);
rve.TopLevelEditor.SetUndoGroupMode(True);
try
rve.InsertPicture('', gr, rvvaBaseline)
finally
rve.TopLevelEditor.SetUndoGroupMode(False);
end;
finally
pic.Free;
end;
===================================
1-4 steps work normally.

5.save to the stream:
TS := TStringStream.Create('');
try
rve.SaveRVFToStream(TS,False);
TS.Position := 0;
Memo1.Lines.Text := TS.DataString;
finally
TS.Free;
end;
( transport the data by tcp/ip sometimes,so not use memory stream)

6.load from the stream:
TS := TStringStream.Create(Memo1.Lines.Text);
try
TS.Position := 0;
rve.LoadRVFFromStream(TS);
finally
TS.Free;
end;
===================================
The gif picture can not show normally.
maybe I lost some steps?
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Call RegisterClass(TGifImage) in initialization. And call rve.Format after rve.LoadRVFFromStream.
greatsea
Posts: 14
Joined: Sat Nov 05, 2011 5:54 pm

Post by greatsea »

That is good.Thank you very much,Sergey.
Post Reply