tappatappa Posted January 22, 2018 Share Posted January 22, 2018 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? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 22, 2018 Share Posted January 22, 2018 Hi, This post can help you: http://forums.unigui.com/index.php?/topic/6619-native-imagelist/ Best regards, Quote Link to comment Share on other sites More sharing options...
tappatappa Posted January 23, 2018 Author Share Posted January 23, 2018 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 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted January 25, 2018 Share Posted January 25, 2018 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, Quote Link to comment Share on other sites More sharing options...
tappatappa Posted January 25, 2018 Author Share Posted January 25, 2018 it seems exactly what I tried, only in Delphi Quote Link to comment Share on other sites More sharing options...
tappatappa Posted January 25, 2018 Author Share Posted January 25, 2018 Let me clarify: The line ImgList->GetPng(img_cache.index, p); Is only a cut and paste error. It wass supposed to be ImgList->GetPng(0, p); Quote Link to comment Share on other sites More sharing options...
tappatappa Posted January 29, 2018 Author Share Posted January 29, 2018 See the test case attached. TestUniImage.zip Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.