Hello,
I have a little pixel-calculation-problem :
T want to crop something from a zoomed area.
I need to calculate backwards to 1:1 the mouseclick-position from a zoomed area.
In this sample :
1:1 ( original ) Top = 40, Left = 40, Bottom = 220, Right = 220
with Zoom-factor = +40%
Result of backward-calculation ( wrong ) :
Top = 34, Left = 34, Bottom = 184, Right = 184
It seems, the calculation is non-linear
The calculation : click-position reduced with 40%
nZoom = 2 = 40%
Sample 1. Line Top/left click-position = 56
nCropTZ ( Top original ) = 56 - ( 0.4 * 56 ) = 34 ( but needed 40 from original )
nCropTZ := nCropT - ( 0.2 * nZoom * nCropT ) // Top original
nCropLZ := nCropL - ( 0.2 * nZoom * nCropL ) // Left original
nCropBZ := nCropB - ( 0.2 * nZoom * nCropB ) // Bottom original
nCropRZ := nCropR - ( 0.2 * nZoom * nCropR ) // Right original
For control, it shows the calculated area inside the original 1:1
The results from a zoomed-area :
expected, to be the same ( from original-zize )
Best Regards
Uwe