Skip to content

Instantly share code, notes, and snippets.

@oflarcade
Created January 10, 2019 13:04
Show Gist options
  • Save oflarcade/be16581f13ea3d5773d7615333285117 to your computer and use it in GitHub Desktop.
Save oflarcade/be16581f13ea3d5773d7615333285117 to your computer and use it in GitHub Desktop.
Image width and height
//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