youmoula / jcrop

Automatically exported from code.google.com/p/jcrop
0 stars 0 forks source link

coordinates do not round-trip successfully on a scaled image #73

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
1. Set jcrop to use a large image, with scaling
2. set the selection coordinates to a region in the image
3. read back the selection coordinates

The expected output is to get back the same coordinates as those originally set.

The actual output is that the returned coordinates vary by a few pixels in many 
cases.

I've identified this line in flipcoords() as the cause:

return [Math.round(xa), Math.round(ya), Math.round(xb), Math.round(yb)];

The rounding is performed *before* the coordinates are unscaled, so the extra 
detail is lost before multiplying back up to full scale.

This bug also highlights that the width and height values are calculated before 
unscaling also, which could lead to similar discrepancies.

Original issue reported on code.google.com by joelfinc...@gmail.com on 28 Mar 2012 at 4:54