Here is a workspace demonstrating the above phenomenon:
workspace.json.txt
The workspace didn't capture it, but the "bitmap DPI" setting is 127.
The workspace shows that the image is 2 pixels tall, but at 127 DPI (5 PPI) it should result in a size of 0.4mm, but it instead results in 0.3999...7mm. This causes the resulting gcode to only raster one line of pixels, not two.
This rounding error is because of the DPI to DPM conversion which scales by 25.4 / settings.dpiBitmap. The root cause is that 25.4 doesn't have an exact floating point representation, which leads to the rounding error when dividing it.
This rounding error can be accounted for a few different ways:
Here is a workspace demonstrating the above phenomenon: workspace.json.txt
The workspace didn't capture it, but the "bitmap DPI" setting is 127.
The workspace shows that the image is 2 pixels tall, but at 127 DPI (5 PPI) it should result in a size of 0.4mm, but it instead results in 0.3999...7mm. This causes the resulting gcode to only raster one line of pixels, not two.
This rounding error is because of the DPI to DPM conversion which scales by
25.4 / settings.dpiBitmap
. The root cause is that25.4
doesn't have an exact floating point representation, which leads to the rounding error when dividing it.This rounding error can be accounted for a few different ways:
1.0 / (DPI / 25.4)
as seen here(I'm planning to submit a pull request for this in the next day or two. I just wanted to give you some context before it shows up.)