arkypita / LaserGRBL

Laser optimized GUI for GRBL
http://lasergrbl.com
Other
1.26k stars 497 forks source link

Image import: DPI from EXIF reads 1 count too low #2376

Open XQ6FOD opened 1 month ago

XQ6FOD commented 1 month ago

When importing a BMP or PNG file, with autosize and choosing to set the size from the EXIF data, or using passthrough mode, LaserGRBL reads the DPI value one count too low. For example a 600 DPI image is read as 599 DPI. Consequently the size of the image ends up a little larger than it should be.

Manually entering the correct DPI number results in correct dimensioning (but this workaround can't be used in passthrough mode).

The bug is present in LaserGRBL v7.12.0. I haven't checked other versions. But I saw that the same bug was already reported in 2019, together with a bug affecting rotation. That time the rotation bug was fixed, and the bug report closed, but without fixing the EXIF DPI reading bug!

My OS is Windows 10, in case that matters.

Probably the solution is as simple as adding 1 when reading the DPI value from the EXIF data. I suspect this bug is caused by the eternal problem of whether we start counting at 0 or at 1...