Ram Jam
May 26th, 1999, 05:28 PM
I wanted to stretch some pictures I was drawing at my dialog, but (you can see the source...) the result was not the thing I wanted!
I am looking if the image is smaller than the space I have for it (in this case x=160, y=210). If not I tried to resize it by dividing and that stuff.
In the end I placed it into the middle. (That is the only thing that works!)
The problem is that my pic is always too large. I am sure it is just a thing I am not realizing right now, but very simple.
Hoping for help. Thank you!
int width = image.GetWidth();
int height = image.GetHeight();
int nwidth, nheight;
int left, top;
if((width <= 160) && (height <= 210))
{
nwidth = width;
nheight = height;
left = (160 - width) / 2;
top = (210 - height) / 2;
}
else
{
long dif1 = width / 160;
long dif2 = height / 210;
if(dif2 >= dif1)
{
nwidth = width / dif2;
nheight = height / dif2;
}
else
{
nwidth = width / dif1;
nheight = height / dif1;
}
left = (160 - nwidth) / 2;
top = (210 - nheight) / 2;
}
I am looking if the image is smaller than the space I have for it (in this case x=160, y=210). If not I tried to resize it by dividing and that stuff.
In the end I placed it into the middle. (That is the only thing that works!)
The problem is that my pic is always too large. I am sure it is just a thing I am not realizing right now, but very simple.
Hoping for help. Thank you!
int width = image.GetWidth();
int height = image.GetHeight();
int nwidth, nheight;
int left, top;
if((width <= 160) && (height <= 210))
{
nwidth = width;
nheight = height;
left = (160 - width) / 2;
top = (210 - height) / 2;
}
else
{
long dif1 = width / 160;
long dif2 = height / 210;
if(dif2 >= dif1)
{
nwidth = width / dif2;
nheight = height / dif2;
}
else
{
nwidth = width / dif1;
nheight = height / dif1;
}
left = (160 - nwidth) / 2;
top = (210 - nheight) / 2;
}