StaticImage - Need to load image at runtime

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

User avatar
Das Gurke
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Sat Sep 02, 2006 15:45

StaticImage - Need to load image at runtime

Postby Das Gurke » Wed Jun 13, 2007 08:27

Well, now I know there is a reason why a static image is called StaticImage. But I am in a fairly unpleasant situation and looking for the correct approach.

The Situation:
I have images which are downloaded from a webserver (background thread of course) at runtime. These pictures represent some kind of avatar image which shall be placed in a playerframe. Important is, that these images are temporary, they are deleted when the application exits.

The Problems:
1) Again I am missing a methodname :oops: Something like Window::setImage() seemed to exist a while ago. What should I use today?

2) Assuming the parameters of the "current" setImage method haven't changed, I need a imageset. This is not quite a problem since ImagesetManager::createImagesetFromImageFile() is fairly anything I need. But isnt there any "smarter" solution then creating a whole imageset for a single image? What I am currently doing is:

Code: Select all

   Ogre::ResourceGroupManager *resmgr = Ogre::ResourceGroupManager::getSingletonPtr();
   CEGUI::ImagesetManager*   imgsetmgr = CEGUI::ImagesetManager::getSingletonPtr();

   resmgr->addResourceLocation(".\\Temp", "FileSystem", "Temp");
   
   try
   {
      CEGUI::Imageset* set = imgsetmgr->createImagesetFromImageFile(name + "Playerimageset", name + "profileimage.png", "Temp");
      set->defineImage(name + "/Profileimage", CEGUI::Rect(0.0f,0.0f,114.0f, 113.0f), CEGUI::Point());
   }
   catch (CEGUI::RendererException& e)
   {
      // Probably image not found, we display nothing in that case
   }
Seems a little overwhelming for just loading a single image ...

User avatar
Das Gurke
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Sat Sep 02, 2006 15:45

Postby Das Gurke » Wed Jun 13, 2007 09:30

Whoops, i stumbled over the Window::setProperty() Method. But I don't get it to work :(

This ist the code I use. I replaced some variables with constants to make clear what values are floating around. This Code does not throw any Exception. Only problem is the "missing" Image.

Code: Select all

      //CEGUI::String imagesetname = name + "/Playerimageset";
      CEGUI::String imagesetname = "Marcus/Playerimageset";
      //CEGUI::String imagename = name + "/Profileimage";
      CEGUI::String imagename = "Marcus/Profileimage";

      CEGUI::Imageset* set = imgsetmgr->createImagesetFromImageFile(imagesetname, name + "profileimage.png", "Temp");
      set->defineImage(imagename, CEGUI::Rect(0.0f,0.0f,114.0f, 113.0f), CEGUI::Point());
      
      //CEGUI::String propvalue = "set:" + imagesetname + " image:" + imagename;
      CEGUI::String propvalue = "set:Marcus/Playerimageset image:Marcus/Profileimage";
      
      mPlayerImage->setProperty("Image", propvalue);

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Wed Jun 13, 2007 14:08

Have you checked the log file for clues?

User avatar
Das Gurke
Not too shy to talk
Not too shy to talk
Posts: 31
Joined: Sat Sep 02, 2006 15:45

Postby Das Gurke » Wed Jun 13, 2007 14:16

Jup, nothing I would consider as wrong. But I will digg a little deeper, chances are quite big that the failure is somewhere in my framework (as usual) :oops:

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Wed Jun 13, 2007 17:39

I recommend that you first try with a full image and if that works then define a partial image. That may help identify the bug. For an example of a full image look at the StaticImage entry of WidgetGalore in the wiki.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 21 guests