Guest User

Untitled

a guest
Jun 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. public static function getImageSize(iWidth:Number,iHeight:Number,iMaxWidth:Number,iMaxHeight:Number):Point {
  2. //Keep ratio when scale ! ^^ port from a php class of mine
  3. var dRatio:Number;
  4. var iW_new:Number;
  5. var iH_new:Number;
  6. if (iWidth > iHeight && iWidth >= iMaxWidth) {
  7. dRatio = iHeight / iWidth;
  8. iW_new = iMaxWidth;
  9. iH_new = iW_new * dRatio;
  10. }else if (iHeight > iWidth && iHeight >= iMaxHeight) {
  11. dRatio = iWidth / iHeight
  12. iH_new = iMaxHeight;
  13. iW_new = iH_new * dRatio;
  14. }else if (iHeight == iWidth && iHeight >= iMaxHeight) {
  15. iH_new = iMaxHeight;
  16. iW_new = iMaxHeight;
  17. }else{
  18. iH_new = iHeight
  19. iW_new = iWidth
  20. }
  21. return new Point(iW_new,iH_new);
  22. }
  23. }
Add Comment
Please, Sign In to add comment