From: "A.Appleyard" To: DJGPP AT SUN DOT SOE DOT CLARKSON DOT EDU Date: Fri, 9 Jun 1995 16:03:15 BST Subject: Paintbrush or similar: anyone got a source for it? The `Paintbrush' package in Windows, or anything similar which can change individual pixels: please has anyone got a complete source form of it?, so that I can add to it some features of my own that I would like to add. I suppose that I could write my own completely from scratch; but that would take a lot of my time. With thanks to R DOT Exler AT jk DOT uni-linz DOT ac DOT at for useful information: here is how to write your own black-and-white PCX file:- int wide = <>, high = <>; FILE*F <>; /* typedef struct {unsigned char r,g,b;} color; */ /*-----*/ struct PCXheader { /* 128 bytes */ unsigned char ID,version,code,bitsperplane; unsigned short X0,Y0,X1,Y1,XDPI,YDPI; /* color color16[16]; */ char color[48]; /* palette */ /* best declared that way to be sure that the compiler won't insert a 4th byte after each set of 3 */ unsigned char reserved,planes; short bytesperline,palettetype; char unused[58];} H; /*-----*/ H.ID=10; H.version=5; H.code=H.bitsperplane=1; H.reserved=0; H.planes=1; H.X0=H.Y0=0; H.X1=wide-1; H.Y1=high-1; H.XDPI=300; H.YDPI=300; /* theoretical pixels per inch in X and in Y */ H.bytesperline=(wide+7)/8; H.palettetype=1; for(j=0;j<3;j++) H.color[j]=255; for(j=3;j<6;j++) H.color[j]=0; /* But I suspect that the palette is ignored */ for(i=0;i<58;i++) H.unused[i]=0; fwrite(&H,1,128,F); Then a bitmap of each row left to right in turn from the top down. At the end of each row, fill to right with unused bits to complete the last byte; but it is best if `wide' is a multiple of 8. You must represent blank paper by a 1 bit, drawing by a 0 bit, not vice versa (else Word Perfect, Windows Write, etc drawing the picture out will ink the background and not the drawing!) In this mode, one byte represents 8 pixels. If n adjacent bytes are all the same (n < 64), they can be replaced by one copy of that byte, preceded by the byte (0xc0+n). But don't use this repeating to compress across the boundary between two lines. Therefore, if an unrepeated picture byte starts with two 1 bytes, (i.e. (B&0xc0)==0xc0), to show that it is a picture byte and not a repeat counter, you must insert the byte 0xc1 before it (= `repeat once').