Pos. inside a zoomed Image in relation to original size ?

Pos. inside a zoomed Image in relation to original size ?

Postby ukoenig » Fri Jul 06, 2012 7: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

Image

For control, it shows the calculated area inside the original 1:1

Image

The results from a zoomed-area :
expected, to be the same ( from original-zize )

Image

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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 112 guests