Raster data in PCL
January 27, 2007 2:44 PM   Subscribe

Could someone explain how the raster data in PCL is converted into what is printed on paper.

I have a project where I am capturing the printer data from a Vtech laptop.
It is a toy laptop, but it has printer drivers for several printers, 27.
I wrote a the characters zug in a file, and "printed" it.
The laptop parallel port is connected to my desktop parallel port, and I wrote qbasic program to capture data and write to a file.
I printed zug file 3 times with each different printer driver (9 drivers of the 27 possible) to compare if data was droppped/corrupted.
I got all of my data which was in dec, and I converted to ascii to read it.
I found several documents on "Printer Command Language" to decipher the captured data.
Looking at the data everything makes sense except the raster data in the Transfer raster data lines.

ESC * b 2 W ? ?
ESC * b 8 W ? ? ? ? ? ? ? ?
Transfer raster data. The number between b and W is number of bytes.
These bytes are the "raster data".

I have read a little about RIP (raster image processing) but I'm getting lost.
Should I expect that each printer will interpret the raster data at a level I cannot follow just by looking at the value?
Does the value simply correspond to a shade?
How does the raster data correspond to printing on the paper?
Is the answer to that in the compression mode, in this case TIFF?

Below is a sample of data captured and converted with my notation in ()'s
I left the raster data in dec.
The printer driver was for HP DeskJet Generic.
zug will print out in super basic font, no formating or style.

ESC E (Reset printer)
ESC & l 2 6 A (Paper size A4)
ESC & l 0 o 1 L (Left margin)
ESC * t 1 5 0 R (Raster resolution 150dpi)
ESC * p 1 N ( ? Couldn't find any doc on ESC*p#N)
ESC * p 0 Y (Vertical Cursor Position Units-of-measure)
ESC * b 2 M (Set compression mode 2=TIFF)
ESC * r 1 U (Simple color 1=black&white palette)
ESC * p 1 2 0 X (Horizontal Cursor Position Units-of-measure)
ESC * r 1 A (Start raster graphics)
ESC * b 2 W 250 0 (Transfer raster data, 2 bytes)
ESC * b 2 W 250 0
ESC * b 2 W 250 0
ESC * b 2 W 250 0
ESC * b 2 W 250 0
ESC * b 2 W 250 0
ESC * b 8 W 6 255 254 56 3 129 255 224 (Transfer raster data, 8 bytes)
ESC * b 8 W 6 255 254 56 3 129 255 224
ESC * b 8 W 6 255 254 56 3 129 255 224
ESC * b 8 W 6 0 112 56 3 142 0 224
ESC * b 8 W 6 0 112 56 3 142 0 224
ESC * b 8 W 6 0 112 56 3 142 0 224
ESC * b 8 W 6 3 128 56 3 129 255 254
ESC * b 8 W 6 3 128 56 3 129 255 254
ESC * b 8 W 6 3 128 56 3 129 255 254
ESC * b 8 W 6 28 0 56 31 128 0 224
ESC * b 8 W 6 28 0 56 31 128 0 224
ESC * b 8 W 6 28 0 56 31 128 0 224
ESC * b 8 W 6 255 254 7 227 129 255 0
ESC * b 8 W 6 255 254 7 227 129 255 0
ESC * b 8 W 6 255 254 7 227 129 255 0
ESC * b 2 W 250 0
ESC * b 2 W 250 0
ESC * b 2 W 250 0
ESC * r C (End raster graphics)
ESC * p + 1 8 Y ( ? similar to ESC*p#Y above but makes no sense here)
ESC E (Reset printer)

Thank you for any help.
posted by sailormouth to Computers & Internet (3 answers total) 1 user marked this as a favorite
 
Best answer: If you are not familiar with the "binary" system, you should read about it -- I suspect wikipedia has a good article.

Consider each byte in an ESC * b x W line in order. I'm not sure what the next number signifies--ignore it. The rest of the bytes carry the information for one row of the image, with the first byte appearing on the left.

Then consider the 8 bits in each byte. The highest bit (128) corresponds to the leftmost pixel of that byte, and the lowest bit (1) corresponds to the rightmost pixel of that byte.

If you carefully (or using a computer program) decode the interesting part of the image (the lines with 8 bytes of data, not 2 bytes of data), you will see your letters.

I've put a Python program as well as the output it produces here: http://pastebin.ca/330519
posted by jepler at 3:52 PM on January 27, 2007


Best answer: Youl should look at HP documents like this pdf. More can be found here.
posted by MonkeySaltedNuts at 3:53 PM on January 27, 2007


Response by poster: Thank you Jepler that program illustrated it wonderfully.

MSN Thank you also. Your first link is the doc I found most useful when deciphering the commands. I will take a look at the other docs they have on the second link.
posted by sailormouth at 5:12 PM on January 27, 2007


« Older Going slow?   |   When vous becomes tu Newer »
This thread is closed to new comments.