[Coco] M.E.S.S. Printing

Robert Gault robert.gault at worldnet.att.net
Fri Dec 19 11:51:47 EST 2003


KnudsenMJ at aol.com wrote:

> In a message dated 12/18/03 1:18:25 PM Eastern Standard Time, 
> brianhostetler at purdue.edu writes:
> 
> 
>>I was just wondering if anyone has figured out how to print graphics in
>> MESS.  I have figured out how to print to a file, which works fine for
>> text documents.  I want to print several Cocomax drawings on my Inkjet
>> printer under Windows XP.
> 
> 
> It would be great if someone could dig up or write, then post, an 
> understandable description of one of the simpler Windows file formats, such as .BMP 
> (bitmap) or good old GIF.  Given that info, we could write conversion routines from 
> any known Coco graphics format into BMP or GIF, which any Windows machine's 
> printer drivers know how to print.
> 
> Trying to figure out how to do graphics on your own printer as a wasted 
> effort, similar to trying to keep up with video cards, and modern printers are 
> driven by the main CPU and use proprietary interfaces.
> 
> That's why you'll have to pry my dead fingers (and still be strong enough to 
> pick it up) to get my HP DeskJet 500 away from me.   Everything documented.  
> It will end up on my Linux box one of these days.  Yes, I've even driven it 
> directly from a Linux program.
> 
> Roger Taylor sent me some GIF docs (thanks again), but some key info at the 
> bit level is missing.    GIF also uses complex compression schemes, so probably 
> BMP is our best hope.  I've done a little bit of Hex dumping of simple BMPs, 
> but haven't gotten far with reverse engineering them yet.  --Mike K.
> 
Don't try to reinvent the wheel :) Look for two (or more?) books by 
Steve Rimmer published by Windcrest/McGraw-Hill. "Bit-Mapped Graphics" 
and "Supercharged Bitmapped Graphics" contain both file formats and 
useful code.

Here is a brief (and probably inadequate) explanation of the BMP file 
structure.

typedef struct {
	char id[2];
	long filesize;
	int reserved[2];
	long headersize;
	long infoSize;
	long width;
	long depth;
	int biPlanes;
	int bits;
	long biCompression;
	long biSizeImage;
	long biXPelsPerMeter;
	long biYPelsPerMeter;
	long biClrUsed;
	long biClrImportant;
	} BMPHEAD;

These are Intel style values not Motorola. ID field is always BM. 
Headersize refers to a sub header that defines the image data. Infosize 
is always $28. BiPlanes is always 1. Bits are 1,4,8, or 24 bits of 
color. BiCompression is always 0, off.

Immediately following the BMPHEAD is either the color palette if used or 
the image data. Palette data has the following structure:

typedef struct{
	char blue;
	char green;
	char red;
	char filler;   * always 0*
	} RGBQUAD

Image data is stored in contiguous lines of inverse order; i.e. first 
line is bottom of screen.

The best way to understand .bmp files is to create simple prototypes and 
study the results with a raw file editor. Create files of equivalent 
size that are all white with 2,8, or 24 bit color and see how the file 
changes. Add a black straight line across the screen and see what 
happens to the data. Repeat with a colored line.




More information about the Coco mailing list