Mail Archives: djgpp/1996/12/18/20:43:28
>> I have written code that seems to read in the first 128 bytes,
>> which is the header for the pcx file. But when I look at it, it's
>> gobble-de-gook, you can't read it. I've even tried reading it as a pcx
>> structure. All my reads were done on the file opened in binary mode. Once
>> I read in the header via binary, it even shows as garbage when I try to
>> access individual header elements via my structure member variable after
>> reading it into the structure. Can anybody tell me what's wrong?
>
>Take a look at the PCX code on my page. It's written for DJGPP.
>
>My guess is that you're missing a "__attribute__ ((packed))"
>somewhere...
>
I've had the same problem, my solutions is :- The place you copied the structure
of the PCX header struct from assumed 16 bit INTs whilst DJGPP/GNU C uses 32 bit
ints. So just change any variable initialises from:-
typedef struct
{
:
:
:
unsigned int xmax;
unsigned int xmin;
: // i cannot remember the rest of the structure
:
}PCX_header,*PCX_header_ptr;
TO:
typedef struct
{
:
:
:
unsigned short int xmax; //shorts are 16 bits in DJGPP
unsigned short int xmin; //the bit sizes of variable types
: ; //can be found in the djsizes.h
:
:
}PCX_header,*PCX_header_ptr;
Adrian Martin.
- Raw text -