Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. private boolean isWidthSmall() {
  2. return imageWidth <= DEFAULT_SIZE;
  3. }
  4.  
  5. private boolean isHeightSmall() {
  6. return imageHeight <= DEFAULT_SIZE;
  7. }
  8.  
  9. private void calcSelectorSide() {
  10.  
  11.  
  12. var wSmall = isWidthSmall();
  13. var hSmall = isHeightSmall();
  14.  
  15. if (wSmall && hSmall) {
  16. selectSideWidth = imageWidth;
  17. selectSideHeight = imageHeight;
  18. return;
  19. }
  20. if (wSmall) {
  21. selectSideHeight = selectSideWidth;
  22. return;
  23. }
  24. if (hSmall) {
  25. selectSideWidth = selectSideHeight;
  26. return;
  27. }
  28.  
  29. double widthRatio = DEFAULT_SIZE / (double) imageWidth;
  30. double heightRatio = DEFAULT_SIZE / (double) imageHeight;
  31. if (heightRatio < widthRatio) {
  32. selectSideHeight = (int) (DEFAULT_SIZE * heightRatio);
  33. } else
  34. selectSideHeight = (int) (DEFAULT_SIZE * widthRatio);
  35. selectSideWidth = selectSideHeight;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement