Scaling mouse co-ordintates for different resolutions

I am working on heatmaps and I have different resolutions [1920x953], [953x502]. I am gathering points from those resolutions and want to draw a heatmap on [1280x768]. But I am getting problems that scaling is not working properly.

I have got mouse co-ordinates(1160,35) in [1920x953], (704,35) in [953x502] and I want to draw these points on [1280x768] resolutions. So, the points must be scaled up/down regarding target resolution. I have used these formulas, but not getting correct value. By the way, (839, 35) is the value of [1280x768].

TargetScreenPoint = (CapturedScreenPoint/Captured Screen Resolution) * Target Screen Resolution  
tsp = (1160/1920) * 1280 = 773

and

Target screen point = (Target Screen Resolution - Captured Screen Resolution)/2 + captured screen point  
tsp = (1280 - 1920)/2 + 1160 = 840  

The first one method is giving wrong value 773. But the second one is giving the correct value which is 840.

But I want to use the generic formula for scaling. Please help in this regard. Thanks!

Answers:

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.