.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Melody Anderson
Eminent IT

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Scaling height width of the object.

Posted By:Lakhan Pal Garg       Posted Date: October 05, 2009    Points: 10    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

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);

Thanks & Regards
Lakhan Pal Garg


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend