createImagesetFromImageFile() image is blurry

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

Arcanor
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Sat Jan 27, 2007 14:03
Contact:

createImagesetFromImageFile() image is blurry

Postby Arcanor » Tue Feb 10, 2009 10:45

I'm having a problem using createImagesetFromImageFile(). It seems that it's compressing my image for some reason, and I don't understand what's happening.

Here's the graphic I'm using:
Image

Here's the code I am using to bring the PNG into my application:

Code: Select all

CEGUI::Imageset* imgset;
imgset = CEGUI::ImagesetManager::getSingletonPtr()->createImagesetFromImageFile("logo", "logo.png");
imgset->setAutoScalingEnabled(false);
imgset->setNativeResolution(CEGUI::Size(247, 46));


Here is the code in my layout xml file to put it on the screen:

Code: Select all

      <Window Type="CyberLook/StaticImage" Name="logo">
         <Property Name="UnifiedPosition" Value="{{0,17},{0,18}}" />
         <Property Name="UnifiedSize" Value="{{0,257},{0,56}}" />
         <Property Name="InheritsAlpha" Value="False" />
         <Property Name="Disabled" Value="False" />
         <Property Name="Image" Value="set:logo image:full_image" />
         <Property Name="VertFormatting" Value="LeftAligned" />
         <Property Name="HorzFormatting" Value="TopAligned" />
         <Property Name="Alpha" Value="1" />
         <Property Name="FrameEnabled" Value="True" />
      </Window>


Here's how it looks in my application:
Image

Obviously this doesn't look nearly as nice as the original graphic. Does anyone know why this is happening, and how I can make the image look crisp in CEGUI, just like in the original graphic file?

Thanks in advance! :)
Arcanoria - a SMORPG project - http://www.arcanoria.com

Pompei2
Home away from home
Home away from home
Posts: 489
Joined: Tue May 23, 2006 16:31

Postby Pompei2 » Tue Feb 10, 2009 12:57

What codec are you using to load images? (I mean SILLY, DevIL, ...?)

Arcanor
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Sat Jan 27, 2007 14:03
Contact:

Postby Arcanor » Tue Feb 10, 2009 13:19

Pompei2 wrote:What codec are you using to load images? (I mean SILLY, DevIL, ...?)


Thanks for your idea Pompei2.

I'm using Ogre 1.6.0, which I think uses FreeImage, but I'm not sure how to verify that except to note that in the Ogre dependencies folder there is a FreeImaged.lib, but nothing looking like SILLY.lib or DevIL.lib.

Based on your question and some searching on the Ogre forums, I tried switching from using the OpenGL renderer to using the Direct3D9 renderer, and now suddenly the GUI graphics look crisp and clear. So this seems to be a problem specifically with the Ogre 1.6.0 OpenGL renderer.

I will try updating to the new Ogre 1.6.1 release and see if the OpenGL renderer still causes the problem, then I'll report back here.
Arcanoria - a SMORPG project - http://www.arcanoria.com

Arcanor
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Sat Jan 27, 2007 14:03
Contact:

Postby Arcanor » Tue Feb 10, 2009 17:35

Ok, well I've upgraded to Ogre 1.6.1, but unfortunately I'm seeing the same results. When using Direct3D9 Rendering Subsystem things look great, but when using OpenGL Rendering Subsystem it looks overcompressed/garbled, as described in my initial post in this thread.

Anyone else seeing this problem, or can offer any insights?
Arcanoria - a SMORPG project - http://www.arcanoria.com

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

Postby CrazyEddie » Tue Feb 10, 2009 19:44

Hi,

My first thought when looking at the images was that it was an autoscaling issue, although I see you are disabling that. However, I'll continue on with some info about that first and how to use the native resolution since it might be helpful at a later time, or to other people...

Basically, you are very unlikely to want the native resolution set to the same size as the source texture image. The native resolution specifies the screen resolution at which the auto-scaling feature will produce a 1:1 mapping when the image is drawn otherwise unscaled. The idea of this feature is to enable imagery to keep the same physical size at different resolutions. As such, you normally will be setting it to a "screen resolution" such as 1024x768 or 800x600 or so on. Having done this, when running at resolutions higher than the set native resolution, the images from the imageset will be scaled up, and when running at resolutions lower then the native, the images will be scaled down (though this rarely gives satisfactory results).

Ok, back to the issue at hand. Because you're using Ogre, the current CEGUI renderer implementation for Ogre requires that your source images all have power-of-two dimensions - if you do not follow this guideline, results will be inconsistent. I think this is likely where your issue is.

HTH

CE.

Arcanor
Not too shy to talk
Not too shy to talk
Posts: 38
Joined: Sat Jan 27, 2007 14:03
Contact:

Postby Arcanor » Tue Feb 10, 2009 21:10

Thanks CE, your suggestion worked. If I create all my images as powers of two (256x256, 1024x1024, etc.) they work fine, without distortion.

Currently I'm using TOP and LEFT alignment, and just ignoring the rest of the imagesets created from file. This works fine, but seems wasteful of all the empty space in the image files.

So I'm wondering how I can use only a portion of an imageset created with createImagesetFromImageFile(). Hopefully this will allow me to combine images into a single file so as to waste less space. Is this possible?
Arcanoria - a SMORPG project - http://www.arcanoria.com

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

Postby CrazyEddie » Tue Feb 10, 2009 21:17

Hi,

Yes, you can combine multiple images on a single texture, this is what an "Imageset" was designed to do :)

You can either specify the component images via XML (see the CEImagesetEditor tool, and also the existing imageset XML files). Or, define the component images manually by using the defineImage function of Imageset (so you create the imageset via the image, then you define the sub-images on the resulting Imageset).

With regards to a single image on a 'big' texture and all the wasted space, this currently only affects the Ogre renderer, and will be addressed in the forthcoming rewrite.

CE.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 14 guests