Page 1 of 1

TGIFImage and Clear()

Posted: Tue Jun 20, 2006 7:47 pm
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.

Posted: Tue Jun 20, 2006 8:22 pm
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); 

Posted: Tue Jun 20, 2006 9:38 pm
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.

Posted: Wed Jun 21, 2006 8:44 pm
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.