Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static function getImageSize(iWidth:Number,iHeight:Number,iMaxWidth:Number,iMaxHeight:Number):Point {
- //Keep ratio when scale ! ^^ port from a php class of mine
- var dRatio:Number;
- var iW_new:Number;
- var iH_new:Number;
- if (iWidth > iHeight && iWidth >= iMaxWidth) {
- dRatio = iHeight / iWidth;
- iW_new = iMaxWidth;
- iH_new = iW_new * dRatio;
- }else if (iHeight > iWidth && iHeight >= iMaxHeight) {
- dRatio = iWidth / iHeight
- iH_new = iMaxHeight;
- iW_new = iH_new * dRatio;
- }else if (iHeight == iWidth && iHeight >= iMaxHeight) {
- iH_new = iMaxHeight;
- iW_new = iMaxHeight;
- }else{
- iH_new = iHeight
- iW_new = iWidth
- }
- return new Point(iW_new,iH_new);
- }
- }
Add Comment
Please, Sign In to add comment