Message-ID: <379250C4.75E26132@go.ro> Date: Mon, 19 Jul 1999 01:10:12 +0300 From: Radu Georgescu aka skoola X-Mailer: Mozilla 4.5 [en] (Win95; I) X-Accept-Language: en MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: decoding pcx header References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com > hey there, I'm having some trouble decoding the pcx header. I hunted down > the format and everything, but I still can't seem to be able to read the > dimensions of the image from the header. If anybody knows anywhere I could > get some info on doing this I'd really appreciate it. Basically, I've tried > reading it as a text file and as a binary file, and I've tried reading > character by character and through formatted input (ie using fscanf) but I > can't seem to get it to work. Anyway, thanks for any help you can offer. you should read the file as a binary file. there should be something like this: int loadpcx(char fila[13],long dest,int mem_pitch,int loadpalette,palette pal) { FILE *f; int pcx_width,pcx_height,bpl,y,x; unsigned char scale,delta,r,g,b,ch,c,*pixel=(unsigned char *)dest,nume[24]="pcx\\"; delta=(loadpalette>>8)&0xff; scale=(loadpalette>>16)&0xff; strcat(nume,fila); f=fopen(nume,"rb"); if(!f) return 1; getc(f); getc(f); getc(f); c=getc(f); if(c!=8) { fclose(f); return 2; } pcx_width=getc(f); pcx_width+=256*getc(f); pcx_height=getc(f); pcx_height+=256*getc(f); pcx_width+=getc(f)+1; pcx_width+=256*getc(f); pcx_height+=getc(f)+1; pcx_height+=256*getc(f); getc(f); getc(f); getc(f); getc(f); for(y=0;y<16;y++) { getc(f); getc(f); getc(f); } getc(f); if(getc(f)!=1) { fclose(f); return 3; } bpl=getc(f); bpl+=256*getc(f); for(y=0;y<60;y++) getc(f); for(y=0;y