zoom an image to fit a screen horizontally - algorithm -
To fit this screen width, there is a general question about algorithm to zoom an image, some givens And some obstacles. We can assume that we are using Java but this question is more mathematical mathematical based on that language.
First of all, the image fits in the dimensions of the load and the screen, not the first horizontally.
We can obtain the dimensions of the screen and The dimensions of the image with the methods, but we can not set the dimensions of either (we are not just set sets).
imageWidth = image.getWidth (); // integer image hight = image.getHeight (); // integer screen width = screen.getWidth (); // integer screen light = screen.gatehit (); // integer
The only way to resize the image is by setting the scale (essentially zooming).
image.setScale (some float); // Alternative Image. Setup (integer);
What I would like to know is how to calculate scale (zoom) level for some LXH image so that it fits horizontal L xH screen?
What you need to do to fill your screen x
axis:
scaling_factor = screen.getWidth () / Image .getWidth () image.setScale (zoom_factor);
The formula is very intuitive:
- The height of the image is irrelevant. Unless the width of the image increases, your scaling factor decreases
- The scales you want to be scaling should be as long as the landscape and the vertical image, as long as the width of the two images is the same
- When your screen size increses, the scaling factor increases.
Comments
Post a Comment