Loading tgui::Picture

Started by china92, 25 May 2013, 15:41:45

china92

Is there any plans for other methods of loading tgui::Picture? It would be nice if tgui::Picture could be loaded from sf::Image or sf::Texture.
Right now I have to do a small workaround like this:

Code (cpp) Select
sf::Image test;
tgui::Picture::Ptr test2(some group);

test.saveToFile("temp.png");
test2->load("temp.png");


@Edit
To ensure the getLoadedFilename() method compatibility it could return empty string if tgui::Picture is loaded from sf::Image/sf::Texture.

texus

There aren't really any plans for that yet.
I would have to keep track whether or not the image was loaded from a file or not. It's not such a big change but I'm looking for a cleaner alternative.

But there is another workaround: create a panel with the size of the texture and use setBackgroundTexture on it.

In the future there will be another possibility because I will add an sfml canvas so that you can draw an sfml sprite in between tgui objects. (See blog post about combining sfml and tgui rendering)

china92

Okay, but the Panel holds only the pointer to the texture, right? So then I have to make sure the texture exists?

Nice, so I'm looking forward to it. :)

texus

Quote from: china92 on 25 May 2013, 16:52:10
Okay, but the Panel holds only the pointer to the texture, right? So then I have to make sure the texture exists?
Yep