printer-driver-ptouch icon indicating copy to clipboard operation
printer-driver-ptouch copied to clipboard

Add internal halftone filters (Error Diffusion, Nonlinear Laplacian)

Open vintagepc opened this issue 9 months ago • 0 comments

Per the discussion in #39 - this adds an actual half-tone filter to the driver.

It may also add some value to #37 to improve the output.

The source for these filters was sourced from the driver for a Dymo LabelWriterPnP linux package and is GPL-v2.

Generally, my experience has been that Error Diffusion provides better results for greyscale text, and NLL will work better for images and non hard-edged graphics

It is currently in draft stage for the following reasons:

  • [ ] Not integrated into Makefile. I've never used autotools and my distro doesn't offer 2.71 :upside_down_face: (that's also why it's a few commits behind the latest...)

My compile command line looks like this:

g++ rastertoptch.c halftoning//ErrorDiffusionHalftoning.cpp halftoning/Halftoning.cpp halftoning/NonLinearLaplacianHalftoning.cpp -I . -lcups -lcupsimage
  • [ ] Not integrated into XML. I am not sure how to add an option that supports both sending the requisite information to CUPS to get an 8bpp image as well as pass options to the driver. Namely, we need this block to set the correct depths:
*OpenUI *Halftone/Halftoning: PickOne
*OrderDependency: 20 AnySetup *Halftoning
*DefaulHalftone: ErrorDiffusion
*Halftone Default/Default: "<</cupsColorOrder 0/cupsColorSpace 3/cupsBitsPerColor 1/cupsBitsPerPixel 1>>setpagedevice"
*Halftone ErrorDiffusion/Error Diffusion: "<</cupsColorOrder 0/cupsColorSpace 1/cupsBitsPerColor 8>>setpagedevice"
*Halftone NLL/Nonlinear Dithering: "<</cupsColorOrder 0/cupsColorSpace 1/cupsBitsPerColor 8>>setpagedevice"
*CloseUI: *Halftone

and the following parameters must be passed to rastertoptch depending on the selected value:

Default: Halftone=-1
ErrorDiffusion: Halftone=0
NLL: Halftone=1

There may also be value in allowing the user to select the threshold value for the Laplacian filter, but that would require detailed analysis with a lot of images - not really what tape label printers are meant for but it may have value for e.g. the QL series?

Some examples for a simple black-to-white gradient:

Input: gradient Default: gradient1 Error Diffusion: gradient21 NLL: grad64-31

vintagepc avatar Sep 30 '23 22:09 vintagepc