I have an algorithm for the editing of an image. There is an image and a rectangle that is smaller than the image (e.g. 3/4 of it) and that represents a section of the image. This section has to be zoomed in or out. It's okay, if the section gets bigger than the image.
Starting basis of the calculations (values relating to the section):
- zoom_factor in range from 0 to 5 (< 1 means zoom in, > 1 means zoom out) (this value is converted, originally it's from -1 to 1, negative meaning to zoom out)
- previous_width (e.g. 800)
- previous_height (e.g. 600)
- previous_x (left margin)
- previous_y (top margin)
("previous" doesn't mean that multiple zooms are made in succession.)
- width = previous_width * zoom_factor
- height = previous_height * zoom_factor
- x = previous_x + (previous_width - width) / 2
- y = previous_y + (previous_height - height) / 2
At the end the section with its contents is always resized to a fixed size (with the same aspect ratio).
The problem is: The zoom progression is not linear. Why? And how can that be changed?