Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert grayscale algorithm changes #37

Merged
merged 3 commits into from
Jan 1, 2023

Conversation

Cellivar
Copy link
Owner

@Cellivar Cellivar commented Jan 1, 2023

As part of #22 I introduced the BitmapGRF class that was heavily based on another nodejs library. As it turns out the grayscale conversion method that library uses is far less tolerant of anti-aliasing or other effects that drawing to a canvas can generate.

The side-effect here was a hard to nail down issue with printed text looking awful. After lots of debugging I decided to revert the image conversion logic back to the color theory based version I wrote last year and this cleared up the issue. The threshold values now work much more effectively and have been returned back to the default 70% they used to be. Prints look much sharper and the font looks much crisper.

To facilitate the debugging I had modified the demo app to show the preview as rendered by the BitmapGRF class, which generates a much more "this is what the badge will actually print like" preview. I've decided to keep this as a good example of how the library ends up rendering text and images. The demo app is starting to get longer than I think is appropriate for a 'basic example code demo' and I'm considering forking it into an 'advanced test app' demo showing more features. This might include more sliders for text control, adding in full image files, and advanced controls like resetting a printer to default values and altering cut controls.

As part of this I identified a couple of other bugs with the bounding box calculations that have been fixed.

@Cellivar Cellivar marked this pull request as ready for review January 1, 2023 09:21
@Cellivar Cellivar enabled auto-merge (squash) January 1, 2023 09:21
@Cellivar Cellivar merged commit 6e28d13 into main Jan 1, 2023
@Cellivar Cellivar deleted the bugfix/revert-grayscale-algorithm branch January 1, 2023 09:21
@github-actions
Copy link

github-actions bot commented Jan 1, 2023

Code coverage

Filename Statements Branches Functions Lines
src/Documents/BitmapGRF.ts 74% 72.09% 76.19% 72.87%
src/WebZlpError.ts 33.33% 100% 50% 33.33%
src/index.ts 100% 100% 100% 100%
src/Documents/Commands.ts 28.41% 43.33% 11% 11.35%
src/Printers/Configuration/PrinterOptions.ts 26.32% 66.67% 6.67% 12.5%
src/Printers/Models/PrinterModel.ts 38.1% 18.18% 11.11% 13.33%
src/Printers/Configuration/SerialPortSettings.ts 97.06% 100% 85.71% 85.71%
src/Printers/Configuration/MediaOptions.ts 69.23% 33.33% 62.5% 20%
src/Documents/ConfigDocument.ts 34.38% 0% 35.29% 34.38%
src/Documents/Document.ts 40.91% 0% 33.33% 45%
src/Documents/LabelDocument.ts 52% 69.23% 29.41% 45.45%
src/Documents/ReadyToPrintDocuments.ts 27.27% 100% 0% 22.22%
src/Printers/Communication/LineBreakTransformer.ts 0% 100% 0% 0%
src/Printers/Communication/PrinterCommunication.ts 76.92% 50% 50% 50%
src/Printers/Communication/UsbPrinterDeviceChannel.ts 4.23% 0% 0% 4.23%
src/Printers/Languages/EplPrinterCommandSet.ts 13.73% 13.85% 12.5% 14.38%
src/Printers/Models/PrinterModelDb.ts 11.54% 0% 0% 11.54%
src/Printers/Models/EplPrinterModels.ts 15.38% 100% 0% 15.38%
src/Printers/Languages/PrinterCommandSet.ts 20.41% 6.25% 17.24% 19.35%
src/Printers/PrinterCommunicationOptions.ts 0% 100% 0% 0%
src/Printers/Printer.ts 11.46% 0% 0% 11.58%
src/Printers/Languages/ZplPrinterCommandSet.ts 3.62% 0% 0% 3.65%
src/PrinterUsbManager.ts 4.35% 0% 0% 4.55%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant