FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Pos. inside a zoomed Image in relation to original size ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Pos. inside a zoomed Image in relation to original size ?
Posted: Fri Jul 06, 2012 07:57 AM
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 :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.

Continue the discussion