These were two frustrating days just now. Here are some things you probably didn’t know:
Trivia fact #1 – As far as I can see, there is no Java code for creating a monochrome PCX file anywhere in the Internet. Perhaps not even any kind of code.
Trivia fact #2 – All the documentation on PCX that Google has to offer, unless I somehow missed it, seems to overlook some very important details about dealing with monochrome images.
Result – if you need your code to create a monochrome PCX file, prepare for some reverse-engineering. Which won’t be easy, considering:
Trivia fact #3 – There are no monochrome PCX images to be found on the Internet. Anywhere.
On the plus side – I don’t know about you, but any time I solve a problem and the solution includes using a hex editor, I feel a little bit of the “omnipotent hacker” aura surrounding me. Next time aliens invade earth and someone needs to upload a virus to their computers – I’m waiting for your call, united Earth government.
In case anyone else ever has the same need and reached this post in some desperate googling (or whatever you future people use for web searches) – in monochrome PCX, the palette is meaningless. Every “color” byte represents not a single color, but 8 pixels where for each bit, 1=white and 0=black. I’m not entirely sure how the RLE works there (will it make repeating patterns 8 pixels long? can you make 6 pixel long single byte values?), I just took the lazy way and prefixed each byte with 0xC1, thus pretty much ignoring RLE and needlessly doubling the size of my data (but greatly improving my day). It works.
 Actually, I might want to prefix that with trivia fact #0.5 – PCX still exists. As in “being used by humans in the 21st century”.