Scaling height width of the object.

In This Sample you need maximum width of the object 1024 and maximum height 750; You need to pass the width and height of object (dblWidth AND dblHeight) and you will get the scaled height and width of the object.

Sample Code:
Double dblWRatio =0

//Actual Width of the Object
Double dblWidth =1280;
//Actual Height of the Object
Double dblHeight =960

//Maximum width of the Object
Double PalyerWidth =1024;
//Maximum height of the Object
Double PlayerHeight =750;

dblWRatio = ((PalyerWidth - dblWidth) * 100) / dblWidth;
dblWidth += dblWidth * (dblWRatio / 100);
dblHeight += dblHeight * (dblWRatio / 100);

if (dblHeight > PlayerHeight)
{
dblHRatio = ((PlayerHeight - dblHeight) * 100) / dblHeight;
dblWidth += dblWidth * (dblHRatio / 100);
dblHeight += dblHeight * (dblHRatio / 100);
}

0 comments: