Fatrat's BeOS Projects: PCX Translator



BeOS translator add-on to allow use of PCX images in translator-aware BeOS applications.

Current version: 0.11 --- PCX_Translator_0.11.zip


Project notes...


2004.08.04 (v:0.11) - Hmm, so much for standards. I managed to get the palette-ized EGA (16 color) and VGA (256 color) modes working, as well as Truecolor (16M color) with a bit of work tonight. My time spent doing low-level coding with the good ole' CGA/EGA/VGA adaptors is serving me well, since the PCX data is often packed in the same weird patterns that those graphic adaptors use. Fun, fun. Truecolor was an annoying revelation -- none of the documentation I've seen mentions that mode, which I'm guessing is because it came about well after the .PCX standard was published. I've grabbed a bunch of files off the internet and run them through the translator, and most of them seem to be working ok now. Haven't been able to find one in CGA format, going to have to see if I have a paint program on a Windows box that can write that format. I don't see supporting the CGA modes as being all too important, but I'd like to have the translator be complete... I will probably post a file documenting the various modes I found here, or pack it in with the source code when I finally get the translator cleaned up enough to release the source.

  The big performance improvement I managed to get in this version came from sucking in the entire input stream when doing the conversion, then doing the byte-by-byte decoding of the RLE stream. I was lazy and pulled it all in as one chunk instead of just buffering it in decent sized pieces, so I have to set aside a good deal of memory to handle the possible worst-case scenario of the file being completely redundant. And it turns out that the .PCX file that inspired me to start making this translator in the first place is indeed a worst-case compression scenario, 1.1MB of totally bloated .PCX image data! (A raw dump of the image would take up one half of that space, the RLE compression in the file is 100% inefficient.)

  Next task is going to be to figure out a good configuration view for setting the parameters that affect writing PCX files out, and then adding in the ability to the translator to actually dump PCX images when asked. This could get pretty tricky, as I will have to deal with converting between all kinds of palettes, color spaces, and so on. Ick. I think a basic one that writes out 256-color, 16M color, and maybe monochrome formats would be more than sufficient.


2004.08.03 (v:0.10) - So I was going to finally get back to doing some BeOS programming now that I'm between semesters at college, and one of the fun projects I had queued up was to make a driver for the Gravis GrIP Multiport joystick adaport thingie I bought awhile ago. (There is a Linux driver project that popped up for this device recently, so I figured I'd try to make a BeOS one... It's a cool device: four SNES-style controllers multiplexed off of one PC Joystick port.) In the documentation from Gravis there's a .PCX image file, and I didn't have a translator loaded for that format on my machine. Hmm. I thought to myself, "I always did want to try writing a translator, I wonder how hard it'd be..."

  A few hours later after pouring over the PCX image "standard" for entirely too long, and looking over the XPM translator source on BeBits, I have a partially working (read-only) translator for .PCX images :) It deals with the most popular formats, but the more obscure ones (CGA and EGA style 4 and 16 color modes, ugh!) along with some of the palette colorizations aren't quite right. At this point I've put enough time into it that I will probably work out the rough edges so that it translates all of the standard .PCX formats, and hopefully add the ability to write images in .PCX format (something that the two existing .PCX translators out there for BeOS lack, but then again, a world with fewer .PCX images is probably a good thing... ;) )

  The hardest thing about comlpeting this translator will be making it super-robust, because the .PCX format is so badly abused. There are many variants and improper hacks in the format that various image manipulation programs have adopted over the years (the .PCX format is from the time when MS-DOS ruled supreme on the PC!) There is also a .DCX format floating around out there that encapsulates up to 1023 .PCX images into one collection, but that's something I may just steer clear of for now...




Back to the main projects page


Email me with comments, etc. --> fatrat@fat-rat.com