creating imagesets

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

Lastmerlin
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Sat Mar 08, 2008 17:25

creating imagesets

Postby Lastmerlin » Sat Apr 05, 2008 15:07

I tried creating a little test imageset. It consists of a four 50x50 images placed in a 100x100 tga.

The .imageset file is:

<?xml version="1.0" encoding="UTF-8"?>

<Imageset Name="test" Imagefile="test.tga" NativeHorzRes="800" NativeVertRes="600" AutoScaled="true" >
<Image Name="flame" XPos="0" YPos="50" Width="50" Height="50" />
<Image Name="sword" XPos="0" YPos="0" Width="50" Height="50" />
<Image Name="shield" XPos="50" YPos="0" Width="50" Height="50" />
<Image Name="nothing" XPos="50" YPos="50" Width="50" Height="50" />
</Imageset>


Everything looks fine in the the CEGUIImagesetEditor

The code using the image is:
label = win_mgr.createWindow("TaharezLook/StaticImage", name.append( "Label") );
label->setProperty("FrameEnabled", "true");
label->setProperty("BackgroundEnabled", "false");
label->setPosition(CEGUI::UVector2(cegui_reldim(0.2f), cegui_reldim(0.05f)));
label->setSize(CEGUI::UVector2(cegui_reldim(0.13f), cegui_reldim( 0.1f)));
label->setProperty("Image", "set:test image:shield");



It was a Text label before, thats why it is called Label. There is something in the image, but it is the wrong part of the TGA displayed. The content of the image is approx. the ((0,20) to (50,70). If it worked correctly, it should be ((50,0) to (100,50)) (coordinates of the corners).
When using an image from Taharez Imageset it is correct. So my imageset seems to be wrong in some manner. I placed a teal point in the TGA on (50,20), it should be on the border of the image. But it is nearly centered.

I can make some screenshots.

Any idea whats wrong there ?
And what does this *native resolution* do ?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Sat Apr 05, 2008 16:12

Hi,

You will likely need to make your tga dimensions some power of two (so in this case 128 x 128). That will fix the positional issue.

The native resolution is our means of allowing images that are specified in terms of pixels to be rendered in a resolution independent way - otherwise the same 32x32 image would appear smaller at 1280x960 that it would at 800x600. Basically the resolution specified is the 1:1 mapping resolution. When the actual screen resolution is higher than the 'native', the image will be scaled up, and when the actual resolution is lower than the 'native', the image will be scaled down.

HTH

CE.

Lastmerlin
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Sat Mar 08, 2008 17:25

Postby Lastmerlin » Sat Apr 05, 2008 17:43

Positional issue is fixed - thanks a lot.

The scaling mechanism is still a bit unclear. I chose natural resolution 1024x768 now - that is the size of my application window. My monitor has 1680x1050. When I open the tga in GIMP, the picture is notably bigger than the image that shows up in the application. Why that :?

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Sun Apr 06, 2008 09:33

Hi,

i can understand that the scaling mechanism is a bit unclear, because maybe it's actually the reverse of what it seems to do. My own idea when i read 'autoscaled=true' would be that an image gets stretched up when the resolution gets bigger. But it means that an image is scaled up or down towards the resolution which you defined in your imageset file.

Would this explaination match which the size difference between Gimp and your in-game window?

HTH.
Check out my released snake game using Cegui!

Lastmerlin
Not too shy to talk
Not too shy to talk
Posts: 33
Joined: Sat Mar 08, 2008 17:25

Postby Lastmerlin » Sun Apr 06, 2008 21:00

Does this mechanism use the monitor resolution or the size of the cegui window ?
The natural size specified in the imageset matches exactly the size of the render window. So the only explanation for me is, that monitor resolution matters. As 1024:768 is a different ratio than 1680x1050 I'd like to know how this works. And I dont understand why it is scaled down, as on such a high resolution the image will appear smaller and scaling up seems more logical to me.

Perhaps the best idea is simply to scale the image, so that it fits exactly its staticImage Window. I guess there is some property to achieve this.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Mon Apr 07, 2008 08:47

The size used by the scaling code is whichever size CEGUI has been told is the current display resolution - in reality this might be the actual resolution, the size of the window in a windowed app, the size of a viewport (i.e. only part of a window/screen), or some other arbitrary values.

As with all external events, CEGUI does not detect changes automatically, and must be informed. Typically this involves calling a member function on the renderer (myRenderer->setDisplaySize() or something).

The auto scaling factors are calculated:

Code: Select all

x_sf = dply_width / native_horz
y_sf = dply_height / native_vert


When an image is drawn without being otherwise stretched to fit a specified area, it's final size is calculated as:

Code: Select all

render_width = pixel_width * x_sf
render_height = pixel_height * y_sf


HTH

CE.


Return to “Help”

Who is online

Users browsing this forum: Bing [Bot] and 4 guests