/* Program to read a 256 colors vga PCX file. */ #include #include #include int return0() {return 0;} int ReadHeader (unsigned & Xlen, unsigned & Ylen, unsigned & BytesPerLine, FILE * f) { char header[128]; fseek(f,0,SEEK_SET); fread((void*)header,128,1,f); if ((header[0]!=10)||(header[2]!=1)) return 1; if ((header[1]!=5)||(header[65]!=1)||(header[68]!=1)) return 2; Xlen = *((int*)(&header[8]))-*((int*)(&header[4]))+1; Ylen = *((int*)(&header[10]))-*((int*)(&header[6]))+1; BytesPerLine = *((int*)(&header[66])); return 0; } /* returns: 0 - O.K. 1 - Not a PCX file 2 - Not a color VGA PCX */ int GetPallete(FILE * f) { unsigned a,b; DacPalette256 pal; fseek(f,-769, SEEK_END); if (getc(f) != 12) return 2; fread(pal,256,3,f); for(a=0;a<256;a++) for(b=0;b<3;b++) pal[a][b]>>=2; setvgapalette256(&pal); return 0; } int DrawImage(int xlen, int ylen, int BpL, FILE * f) { int x=0, y=0, tx,ty,tcol; fseek(f,128,SEEK_SET); int pbyt; /* where to place data */ int pcnt; /* where to place count */ int i; while(y