I have some trouble with some basic math and cant find any infos / math about it on the web.
I am loading and showing a bitmap inside a window and i can zoom it in/out (ImageWidth * ZoomFactor), where ZoomFactor range from int 1 to 32.
A smaller scaled version of the original bitmap will be shown as preview in a so called navigation window (like photoshop).
At this point i know following values/infos:
- The client width and height of the window (where the image will be drawn)
- Original image width and height
- width and height of the scaled/zoomed image (imageWidth * zoomFactor)
- width and height of the preview area (where the scaled down image will be drawn)
- width and height of the image preview (navigation window)
- The zoomFactor ( 1 == 100% | 2 == 200 %... )
QUESTION:
The bitmap preview should show a rect of the area, we are zoomed in / which is visible. (see screenshot from photoshop)
How to calculate the (red) rect of the visible area?
Something i tried (just as example):
ClientWidth = 1024 | ImageWidth = 1280 -----> (100/(ImageWidth*zoomFactor)) * ClientWidth == 80
Also 80 % of the original imageWidth ((1280/100)*80) are visible in this example.
Any idea where to find infos on the web or whats the name of this to search?