maschek / imgmap

Javascript based imagemap editor
https://www.maschek.hu/imagemap/
GNU General Public License v2.0
59 stars 33 forks source link

Cumulative rounding error in changing zoom level #45

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. go to http://www.maschek.hu/imagemap
2. choose sample image 4
3. draw a rectangle with coords 542,154,603,208
4. change zoom level to 25%
5. rectangle coords are now 540,152,600,204 !
6. zoom back to 100%
7. rect coords are now 540,152,600,204 , different from step 3 !

What is the expected output? What do you see instead?
I expect the coordinates to be the same at 100%, whatever zoom level I jump 
between

What version of the product are you using? On what browser/operating system?
I use the latest version 2.2 r108, with Firefox 3.6.11/Windows XP

Please provide any additional information below.
The problem is the coordinates rounding.
A coordinate of 103 at 100 % will be rounded to 51 at 50 %
Then it's 51 x 2 = 102 back to 100 %, we've lost 1 pixel !
If we then switch to 25 % we get 102 x 0.25 = 25
Back to 100 % we get 25 x 4 = 100, we've lost another 2 pixels !
When jumping from one zoom level to another the coordinates can loose 10 to 15 
pixels, which is very annoying.
We use imgmap with big images so we switch zoom very often.  We draw many 
precise zones on these images, so this bug is critical for us.
I am working on a fix to compute every zoom change from original coordinates, 
without the cumulative rounding problem.  I'll submit it if you are interrested.

Original issue reported on code.google.com by svilb...@etai.fr on 22 Oct 2010 at 8:17

GoogleCodeExporter commented 9 years ago
Hi,

Thank you for reporting this problem. Of course I am interested in your fix, 
let me know if you need some assistance.

Original comment by adam.mas...@gmail.com on 26 Oct 2010 at 2:09

GoogleCodeExporter commented 9 years ago
Hi,

Here is a patch that fixes the rounding bug.

Original comment by svilb...@etai.fr on 27 Oct 2010 at 8:11

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you, Stéphane!

Original comment by adam.mas...@gmail.com on 1 Nov 2010 at 2:13