resize IGUIImage?

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
mrbrdo
Posts: 15
Joined: Sun Jan 07, 2007 6:52 pm

resize IGUIImage?

Post by mrbrdo »

hey.. i use different resolutions when i create my window and i want to be able to resize the images accordingly too (for example: the background image is 800x600, i open the window at 640x480, i want to resize the background image to 640x480). Any way of doing this with IGUIImage, or i have to do it with another interface.. If yes, then which\how?

thanks a lot
mrbrdo
Posts: 15
Joined: Sun Jan 07, 2007 6:52 pm

Post by mrbrdo »

i tried:

Code: Select all

    bg_img = env->addImage(env->getScreenRect(rect<f32>(0, 0, 1, 1)));
    ITexture *img = driver->getTexture("data/texture/bg.tga");
    core::matrix4& tran = img->getTransformation();
    tran.setScale(core::vector3df(0.5f,0.5f,0.5f));
    bg_img->setImage(img);
it does resize the texture, but it cuts it off at the size of the original image (so i actually only see 1\4 of the image, the top-left part of it)..
please help me on this one. thanks
mrbrdo
Posts: 15
Joined: Sun Jan 07, 2007 6:52 pm

Post by mrbrdo »

anyone knows about this? thanks
harukiblue
Posts: 49
Joined: Sun Dec 10, 2006 6:23 pm

Post by harukiblue »

Is there a reason you are accessing the transfermation matrix by reference and not ussing a pointer?

Code: Select all

core::matrix4& tran = img->getTransformation(); 
tran.setScale(core::vector3df(0.5f,0.5f,0.5f));
Shouldn't this be . . .

Code: Select all

core::matrix4* tran = img->getTransformation(); 
tran->setScale(core::vector3df(0.5f,0.5f,0.5f));
or try this

Code: Select all

bg_img = env->addImage(env->getScreenRect(rect<f32>(0, 0, 640, 480))); 
bg_img->setImage("data/texture/bg.tga"); 
Hope this helps!
mrbrdo
Posts: 15
Joined: Sun Jan 07, 2007 6:52 pm

Post by mrbrdo »

thanks for trying but "core::matrix4&" is correct, "core::matrix4*" is not (compiler error).

and it should be "bg_img->setImage(driver->getTexture("data/texture/bg.tga"));", not "bg_img->setImage("data/texture/bg.tga");", but that doesn't work, it just makes it so you can only see the 640x480 pixels of the image (it just cuts the image off so it fits the rectange, it doesn't resize it).
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The texture matrix cannot scale the image, it works on the texture coords. So when using original coord (1,1) you would get (0.5,0.5) with your scale factor. And that makes your texture stretch one fourth of itself to the whole image. But indeed the reference is correct, there's always a proper matrix (only for Irrlicht 1.2, though, as this will change for the next release).
But shouldn't the image resize automatically? It's using a pretty simple scaling, though, which will give some artifacts in your image. Thus it's better to have iomages with different resolutions.
mrbrdo
Posts: 15
Joined: Sun Jan 07, 2007 6:52 pm

Post by mrbrdo »

hybrid: it doesn't seem to scale automatically.. i don't mind if the image is slightly distorted because of the scaling.. still need some code to make this work, what i've tried so far did not do it.
Post Reply