Jump to content

TUniImage: load from TUniNativeImageList


tappatappa

Recommended Posts

Is it possible to "copy" an Image loaded in a TUniNativeImageList into a TUniImage?

I tried several approaches, with no luck.

img->Picture->Graphic->LoadFromStream(ImgList->Images[0]->MemoryImage);  //ACCESS VIOLATION

Or

TMemoryStream* s = new TMemoryStream();
TNativeImageRecord* img_rec =  ImgList->Images[0];

img_rec->MemoryImage->SaveToStream(s);  //ACCESS VIOLATION
s->Position = 0;

img->Picture->Graphic->LoadFromStream(s);

Or

TMemoryStream* s = new TMemoryStream();
TNativeImageRecord* img_rec =  ImgList->Images[0];

img_rec->Graphic->SaveToStream(s);  //ACCESS VIOLATION
s->Position = 0;

img->Picture->Graphic->LoadFromStream(s);

Any help?

Link to comment
Share on other sites

Hi Delphi Developer,

 

Thanks for the link. I tried this

TPngImage* p = new TPngImage();
try
{
    ImgList->GetPng(img_cache.index, p);
    p->Transparent = true;
    img->Picture->Graphic->Assign(p);
}
__finally
{
    delete p;
}

And it kinda works. The only problem is that the pictures lose transparency, they get a black background.

P.S. All the images I use are png

Link to comment
Share on other sites

Hi,

var
  P : TPngImage;
begin
  P := TPngImage.Create;
  try
    UniNativeImageList1.GetPng(0, P);
    UniImage1.Transparent := True; //<---------------
    UniImage1.Picture.Graphic.Assign(P);
  finally
    P.Free;
  end;
end;

Best regards,

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...