Resize an image

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
The BasheR
Posts: 73
Joined: Thu Apr 05, 2007 7:01 pm
Location: France
Contact:

Resize an image

Post by The BasheR »

Hi all, i would like to resize an image with Irrlicht but i don't know how to do :(
I've juste read this topic: http://irrlicht.sourceforge.net/phpBB2/ ... size+image
But istill don't know how to do :(

Acutally i would like to load an image, and to resize it to display it with the new size, but i don't want the image to be saved.

Is someone can tell me how to do?
Or if it is not possible with Irrlicht, can you tell me how to do generally?

Thanks a lot.
When you want you can!
Quand on veut on peut!
LLDD
Posts: 43
Joined: Fri May 11, 2007 9:50 am

Post by LLDD »

Load a texture and use draw2dimage.
Example:

Code: Select all

SaveGameTexture=driver->getTexture("save005.bmp");
driver->draw2DImage(SaveGameTexture, rect<s32>(300,30,620,270), rect<s32>(0,0,640,480));
________
Honda Cbx750 Specifications
Last edited by LLDD on Sun Feb 20, 2011 2:10 am, edited 1 time in total.
The BasheR
Posts: 73
Joined: Thu Apr 05, 2007 7:01 pm
Location: France
Contact:

Post by The BasheR »

Ok, but what does this method do exactly? I read the documentation for this method but i don't exactly understand the meaning of all the parameters :(
When you want you can!
Quand on veut on peut!
LLDD
Posts: 43
Joined: Fri May 11, 2007 9:50 am

Post by LLDD »

The BasheR wrote:Ok, but what does this method do exactly? I read the documentation for this method but i don't exactly understand the meaning of all the parameters :(
The first parameter is the texture you want to draw.
Second parameter is a rectangle on the screen where you want to draw the image.
Third parameter is a rectangle of the portion of your image that will be drawn.
________
Rhode Island Medical Marijuana Dispensary
Last edited by LLDD on Sun Feb 20, 2011 2:11 am, edited 1 time in total.
The BasheR
Posts: 73
Joined: Thu Apr 05, 2007 7:01 pm
Location: France
Contact:

Post by The BasheR »

Ok thank, but i would like to use it with transparence so i use it like as following:

Code: Select all

mp_driver->draw2DImage(mp_image, mt_rect_dest[i],
            mt_rect[i], 0, SColor(255,255,255,255), true);
But i have this error:

"error: no matching function for call to `irr::video::IVideoDriver::draw2DImage(irr::video::ITexture*&, irr::core::rect<irr::s32>&, irr::core::rect<irr::s32>&, int, irr::video::SColor, bool)'"

So how can i do to use it with SColo and the boolean, but without having this error?

Thanks
When you want you can!
Quand on veut on peut!
The BasheR
Posts: 73
Joined: Thu Apr 05, 2007 7:01 pm
Location: France
Contact:

Post by The BasheR »

Nobody can help me :(
Is it possible to resize an image AND use the transparency?
When you want you can!
Quand on veut on peut!
Kuehrli
Posts: 6
Joined: Thu May 10, 2007 8:32 am
Location: Linz, AT

Post by Kuehrli »

I guess that this might be the function you are searching for:

Code: Select all

virtual void draw2DImage(video::ITexture* texture, const core::rect<s32>& destRect, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, video::SColor* colors=0, bool useAlphaChannelOfTexture=false) = 0;
So try something like this:

Code: Select all

SColor colors[4];
for(int i=0; i<4; ++i)
    colors[i] = SColor(100,255,255,255);
mp_driver->draw2DImage(mp_image, mt_rect_dest[i], mt_rect[i], 0, colors, true);
The BasheR
Posts: 73
Joined: Thu Apr 05, 2007 7:01 pm
Location: France
Contact:

Post by The BasheR »

Thank you that is working, but what have we to initialize colors like this:

Code: Select all

SColor colors[4];
for(int i=0; i<4; ++i)
    colors[i] = SColor(100,255,255,255); 
When you want you can!
Quand on veut on peut!
Robert Y.
Posts: 212
Joined: Sun Jan 28, 2007 11:23 pm

Post by Robert Y. »

You can just use:

Code: Select all

mp_driver->draw2DImage(mp_image, mt_rect_dest[i], mt_rect[i], 0, SColor(100,255,255,255), true); 
where 100 is the alpha value and 255,255,255 tells Irrlicht to use the colors of the image without filtering.
The BasheR
Posts: 73
Joined: Thu Apr 05, 2007 7:01 pm
Location: France
Contact:

Post by The BasheR »

ok but what is the difference between the 2 ways?
When you want you can!
Quand on veut on peut!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Just read the API documentation for the function. You have to pass an array of four colors which are used as base colors for the four corners of the image. If you use only one color you will get a buffer overrun (which might give you wrong colors or simply a crash).
Robert Y.
Posts: 212
Joined: Sun Jan 28, 2007 11:23 pm

Post by Robert Y. »

Just read the API documentation for the function. You have to pass an array of four colors which are used as base colors for the four corners of the image. If you use only one color you will get a buffer overrun (which might give you wrong colors or simply a crash).
Now I'm confused too. In ivideodriver.h there is also a draw2dimage definition with one SColor. That works fine for me, or am I just lucky?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

There are also two methods which take only one SColor. But those mentioned in this thread are all the same and take an array of four SColors.
The BasheR
Posts: 73
Joined: Thu Apr 05, 2007 7:01 pm
Location: France
Contact:

Post by The BasheR »

Ok, thank you for your answers.
When you want you can!
Quand on veut on peut!
Post Reply