Page 1 of 1

Keeping the aspect ratio of static images.

Posted: Wed Dec 20, 2006 18:41
by jtracy
I am working on a screen that needs to be displayed on both a 4:3 and 16:10 aspect ratio monitors. Right now I have a bar (Default Window) of logos that is displayed on the right side of the screen. When I setup the screen it was using a 4:3 aspect ration, but when I use it on my 16:10 monitor the icons come out squished. Is their anyway to keep this from happening. I want the icons to scale if the resolution changes, but I want them to do that uniformly. If anyone know how to deal with this in CEGUI please let me know.


Posted: Thu Dec 21, 2006 02:31
by Pompei2
I think this has more something to do with your renderer, like DirectX or OpenGL, ... CEGUI doesn't even know of the ratio change, you have to tell CEGUI that it changed.

Unfortunately, I don't know how to detect these changes ^^

Posted: Tue Dec 26, 2006 21:20
by jtracy
Assuming I can detect the change what do I have to tell CEGUI in order to keep it from stretching the images when scaling?

Posted: Tue Dec 26, 2006 21:28
by LennyH
jtracy wrote:Assuming I can detect the change what do I have to tell CEGUI in order to keep it from stretching the images when scaling?

Don't use the relative position or size. You can position all widgets with an absolute position, as well as size all widgets with an absolute size.

Also, you can ( should ) remove the 'AutoScaled="true" ' attribute from the <Imageset> tag in your .imageset file.

And finally, if you're making widgets based around images, you probably want to make sure that the specific parts in the .looknfeel file are set to either tile or stretch as appropriate for your case.

Posted: Wed Dec 27, 2006 14:47
by jtracy
I have tried using absolute size and postition, but that casues problems at different resolutions. We have a requirement to run at low and high resolutions. I am not making widgets out of the images yet, this is just placing some logos on the opening screen.

By using the absolute position and size I either get really large logos on the small screen sizes (the logos interfere with the rest of the interface) and normal logos on the large widescreen resolutions or normal logos on the small screen sizes and tiny hard to read logos on the large widscreen resolutions.

If there is no way to scale an image and keep its aspect ratio then I would think that CEGUI is useless for widescreen resolutions.

Posted: Wed Dec 27, 2006 17:11
by LennyH
You don't get large or small logos on bigger or smaller resolutions. If you are indeed using absolute sizes, then you are specifying the exact amount of pixels that thing will take.

If you are running at a low screen resolution, that amount of pixels will take up a proportionally larger amount of space.

Vice versa for a high screen resolution.

The problem isn't CEGUI. You cannot typically have any image scale and look good, whether scaling down or up [although you'll wind up with better results going down].

Likewise, if you want it to scale, the aspect ratio will of course cause the image to become skewed and look awkward. This isn't a problem with CEGUI.

If you want a clean cut interface at many resolutions, you have to make your graphics [whether they be images or colors or text] look good at the resolutions you're going to support. For unsupported resolutions, you just have to decide what the best way to handle things are, which is usually keeping things at fixed sizes.

There is no magic that can be done here to have something look good in an environment its not designed to handle.

Posted: Sun Dec 31, 2006 12:19
by Pompei2
I see what problem you have. The first idea that comes to my mind is maybe not the "nicest" ... Maybe you should simply create two layouts, one for the 16:9 aspect ratio and one for the 4:3 ?

Posted: Mon Apr 02, 2007 18:29
by Arcanor
I think the original poster's point is significant. I'm looking for a solution to this problem as well. The question is this:

How can an image be "Stretched" (in CEGUI/Falagard terms) and still maintain the original aspect ratio? CEGUI provides ways to align, tile, or stretch an image both horizontally and vertically, but how can we ensure that such resizing preserves the original aspect?

Posted: Tue Apr 17, 2007 14:57
by madmark
I came to this thread from a search.

I too have this question, and I think it is a CEGUI thing. I have a static image in the layout and dynamiclly swap the displayed image. These images are not always in the same size and shape, so I want the images "Stretched" but the original image's aspect ratio to be preserved.

Maybe the best short description is I want "BestFit" and an option for "VertFormat" and "HorzFormat".