Created
January 10, 2019 13:04
-
-
Save oflarcade/be16581f13ea3d5773d7615333285117 to your computer and use it in GitHub Desktop.
Image width and height
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//WIDTH OF THE DEVICE ====> Display.getInstance().getDisplayWidth(); | |
//HEIGHT OF THE DEVICE ====> Display.getInstance().getDisplayHeight(); | |
//WIDTH OF THE IMAGE ====> IMAGE.getWidth(); | |
//HEIGHT OF THE IMAGE ====> IMAGE.getHeight(); | |
img = theme.getImage(`nameOfTheImage.png`); | |
int size = Math.min(Display.getInstance().getDisplayWidth(), Display.getInstance().getDisplayHeight()); | |
if(img.getHeight() < size) { | |
img = img.scaledHeight(size); | |
} | |
// half of the display | |
if(img.getHeight() > Display.getInstance().getDisplayHeight() / 2) { | |
img = img.scaledHeight(Display.getInstance().getDisplayHeight() / 2); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment