TGIFImage and Clear()

General TRichView support forum. Please post your questions here
Post Reply
Jacek Puczynski
Posts: 27
Joined: Tue Jun 20, 2006 7:34 pm
Location: Europe

TGIFImage and Clear()

Post by Jacek Puczynski »

Hello. I have some problems with TRichView and TGIFImage;

Code: Select all

TGIFImage* getimg = new TGIFImage (*mainfrm->Emoty->GetEmotiokon(img));
//TGIFImage* getimg = new TGIFImage ();
//getimg->LoadFromFile("baby.gif");
if(getimg)
{
RichView->AddPictureExTag(img, getimg, -1, rvvaBaseline, 0);
}
I'm using copy creator of TGIFImage becouse I don't want to load image from the disk each time. It's work fine until I call TRichView->Clear() then I have errors in TGIFImage. SOMETIMES when i call Clear (and after it Format) is OK but when I want to insert some text or images after it there errors anyway.
If I load image from the disk each time (comments in code) no errors when Clear() calls.
Why I have that errors (EAccesViolation) and how to solve this?

Thanks, Jacek.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Try to use this code:

Code: Select all

TGIFImage* getimg = new TGIFImage;
getimg->Assign(*mainfrm->Emoty->GetEmotiokon(img)); 
RichView->AddPictureExTag(img, getimg, -1, rvvaBaseline, 0); 
Jacek Puczynski
Posts: 27
Joined: Tue Jun 20, 2006 7:34 pm
Location: Europe

Post by Jacek Puczynski »

Hello. Yes, it works fine for me.

I tried also using TStream to Load and Save TGIFImage. And it also works with Clear().

Which method will be faster - TMemoryStream (Save, Load) or Assign? What do you think?

Thanks, Jacek.
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Assign is better and faster, because the source and the destination graphic classes will share the same graphic object (graphic objects use copy-on-write mechanism). Memory and resources are saved.
Post Reply