PrinterToPDF icon indicating copy to clipboard operation
PrinterToPDF copied to clipboard

Colour support

Open Mike-DE-RE opened this issue 7 years ago • 15 comments

The software I am using can create colour - as far as I know.

I made a file for your that should have coloured output:

TOPLABEL.zip

Here is the result of it's conversion

Mike-DE-RE avatar May 09 '17 17:05 Mike-DE-RE

Wrong button. ;-)

Mike-DE-RE avatar May 09 '17 17:05 Mike-DE-RE

HERE is the result of it's conversion:

PDF.zip

As a matter of fact, it is black and white.

The result should look like this:

toplabel

Oops, didn't see my typing error in the URL.

Mike-DE-RE avatar May 09 '17 17:05 Mike-DE-RE

Hmm - is your software set up to print in colour? The only ESC/P2 codes I can see in the .prn file are ESC @ (reset) ESC J (advance print position vertically) and ESC * (bitmap image dump)...

There should be an ESC r command to change colour but its not in the file - unless there is something I am missing...

RWAP avatar May 09 '17 20:05 RWAP

You are right - my mistake. The software I use has a special switch with which you have to enable colour printing first. Done in

TOPLABEL.zip

Results show colour, see

PDFs.zip

This is a preview of what you should find toplabel

Mike-DE-RE avatar May 10 '17 06:05 Mike-DE-RE

Raw data from RETRO.zip, see https://github.com/RWAP/PrinterToPDF/issues/11

contains

Picture is scaled to 173.4 x 130 mm and centered, it is a screenshot of your website colour reduced to fixed eight colours using Stucki algorithm

and can be used for colour testing as well. Here is the original PCX image:

S8RETROP.zip

Mike-DE-RE avatar May 10 '17 12:05 Mike-DE-RE

Did you see the colour problems in above Word for DOS file?

colour

Might have to do with the latest release of code.

Mike-DE-RE avatar May 11 '17 05:05 Mike-DE-RE

Where is the prn file for the word for dos file? Do these come out correctly on an attached printer?

Oddly the TOPLABEL.zip only sends 3 different ESC r colour commands to the printer (0 BLACK, 1: MAGENTA, 2: CYAN and 6: GREEN) with no mixed colours.

RWAP avatar May 11 '17 08:05 RWAP

Where is the prn file for the word for dos file?

The file is uploaded here https://github.com/RWAP/PrinterToPDF/issues/11

Do these come out correctly on an attached printer?

As a matter of fact, I have no colour dot matrix printer. I cannot check that right now.

Mike-DE-RE avatar May 11 '17 08:05 Mike-DE-RE

OK - I have checked these using a QL emulator on Windows and copied the files to the parallel port). Alas I don't have a colour Epson printer either any more - but the data is captured and processed by another printer capture program (written for Windows) - QPCPrint.

This shows the same issues with the colours, so it looks to be an issue with the printer driver you are using for colour output.

image

RWAP avatar May 11 '17 08:05 RWAP

I am not convinced that the mixed colours are quite right - but there is no easy way to match these with what you would get on a printer that I can see. I shall ask the author of QPCPrint as their colour mix appears a better match

RWAP avatar May 11 '17 21:05 RWAP

Found that

https://upload.wikimedia.org/wikipedia/commons/c/c2/Epson_LQ-2550_сolour_dot_matrix_printer_test_page.jpg

Mike-DE-RE avatar May 12 '17 08:05 Mike-DE-RE

One speed-up would be to create a table to lookup the RGB values for each value fetched from lookupColour, so that it is only called once per colourValue stored in the printermemory. This should improve the speed of generating the PNG image. Open to suggestions as to how to do this.

This is what I know:

Color was achieved through a multi-pass composite printing process. During each pass, the print head struck a different section of the ribbon (one primary color). For a 4-color ribbon, each printed line of output required up to 3 passes depending on color.

https://en.wikipedia.org/wiki/Dot_matrix_printing#Color

So I would assume that in this case the multiple lines would be generated by sending CR without LF at the end of such line that requires to be overprinted in a different colour.

Meaning a section between two LFs is a multi-colour line, right?

Baring in mind that the ribbon was yellow, red, blue and black. I think that should mean that they use CMYK as colour model.

So from my point of view you can determine the print colour only when you have a complete section.

My understanding:

[cyan]Test[CR] [magenta]Test[CR] [yellow][CR][LF] <-- this is a wase line, because it prints nothing.

Should give a mix of 100% cyan and 100% magenta =

[blue]Test[CR][LF].

I would think a do matrix printer should be able to mix 100% colours only, right? I don't think it can regulate the pressure of each needle which would enable it to print 50% of a colour. If so, it reduces the number of possible output colours. Further would I say, that single dots would be overlaying each other, so no mixes like half a dot of red overlays with half a dot of blue (re(d/b)lue), right?

From my point of view you would collect such lines in memory and do a colour calculation on CR/LF and then output the line (pattern in it's mixed colour) to the png.

Mike-DE-RE avatar May 15 '17 15:05 Mike-DE-RE

In reality this is what we do...

I have written a conversion routine to create a CMYK colour from the potential 6 colours supported on ESC/P2 (although some of those would have been mixtures already as most ink cartridges only had CMYK), and ribbons tended to be red yellow and black. The CMYK is then converted to RGB for the pixels in the PNG image.

I agree - it should probably be 100% colour as there is no method of telling the printer anything other than one of the 6 colours. What some programs did was (I think) to use different colours for adjacent dots to give an illusion of a third colour option.

Anyway, the colour lookup table is now created at the start of the program; and indeed the image is built up in memory, mixing the colour parameters per pixel as suggested, so all we need do is to take the colour defined for any given pixel (which can be a mixture of the 6 supported colours) and set the red, blue and green levels according to that lookup.

This is the fastest method of doing it, so I don't think there is anything else we can save.

RWAP avatar May 15 '17 15:05 RWAP

Except of memory. ;-)

Mike-DE-RE avatar May 15 '17 16:05 Mike-DE-RE

I am open to suggestions on how to save memory!

RWAP avatar May 15 '17 18:05 RWAP