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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...