addImage in GUI distorts my Image file??

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
beshrkayali
Posts: 85
Joined: Mon Jun 11, 2007 11:22 am
Location: Damascus - Syria
Contact:

addImage in GUI distorts my Image file??

Post by beshrkayali »

hey all

I'm using addImage to make my game's menu screen, but in the game, my images looks distorted? how can i make it work? with the original image quality?
:cry:
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

I think the dimension of the image is wrong...
It must be in power of 2 (2^0, 2^1, 2^2, 2^3, 2^4, ...) !!!
So be sure the dimensions are correct (for example 512 x 512) ... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
beshrkayali
Posts: 85
Joined: Mon Jun 11, 2007 11:22 am
Location: Damascus - Syria
Contact:

Post by beshrkayali »

thank you :P :P :P
it worked
i didn't know that :D
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

yeah, it's a common error and asked many times here... ;)
A search on the forum probably helped you quicker... :lol:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
eneru
Posts: 40
Joined: Tue Apr 10, 2007 8:38 am

Post by eneru »

addImage uses the original dimension of the texture though, right ?
So even if the image is not a power of 2 it should work... a priori.. ?
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

eneru wrote:addImage uses the original dimension of the texture though, right ?
So even if the image is not a power of 2 it should work... a priori.. ?
That image still has to be sent to your video card, which will get angry at non-power of two images and distort them. There are some video cards out there that handle non-power of 2, but most don't. Basically what this means is this really isn't Irrlicht's fault at all. The closest thing to a fix would be for Irrlicht to determine the closest power of 2 resolution and resample everything.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Dances wrote:The closest thing to a fix would be for Irrlicht to determine the closest power of 2 resolution and resample everything.
AFAIK this is exactly what happens by the graphics card...
the image will be scaled to the next power of 2...
this is the reason why the image looks bad afterwards... ;)

If you use an ITexture you can check if it's scaled with getSize() and getOriginalSize() !!! 8)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
andoba
Posts: 11
Joined: Fri Jul 07, 2006 7:44 pm

Post by andoba »

So, if for example I want to do a image for filling the whole screen (1680x1060, in my case) I'd have to make tiny images that are power of two?

And, why in SDL I can load up that same image and it looks perfect? :?

Sure they're different things, but there is some way for loading images that they're size isn't a power of 2?

Thanks.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

you could load it in to system ram as an image, split into (for example) 256x256 tiles, turn them in to textures and only draw the visible sections
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

You could also make the image higher than the required resolution. Formats like PNG are really forgiving on large amounts of black or white space.
Post Reply