On Sat, 3 Jun 2000, Hans Breuer wrote:

> There is structure packaging with M$VC as well and there is the 
> #pragma pack directive to fix or produce problems with it.

Generally, it is not a good idea to write structures directly to a file
unless you will be reading them again on the same architecture.  If you
are writing cross platform code, it is not really a good idea to rely on
the structure packing rules of the compiler.

> 
> The main reason it appears to work here: it wasn't used, because it's
> only needed for single objects with size > 32767 (My test bitmaps
> were smaller). 
> I'm still investigating a related documentation problem. There seems 
> to be no way to detect if a WPGHead16 or WPGHead32 was used, while 
> reading a wpg file. Maybe the 32 bit version was never used.

The Encyclopedia of Graphics Formats (from oreilly) has a bit of sample
code for reading the header of a WPG record.  The code looks like it is
written for dos or windows use, so it requires a little modification to
work correctly on both little endian and big endian machines (the
GINT16_{TO,FROM}_LE macros (is it little endian?) should help):

  BYTE RecordType;
  DWORD RecordLength;
  FILE *fp;

  RecordType = GetByte(fp);      /* read RecordType */
  RecordLength = GetByte(fp);    /* read RecordLength */
  if (RecordLength == 0xFF) {    /* not a BYTE value */
    RecordLength = GetWord(fp);  /* read next WORD */
    if (RecordLength & 0x800) {  /* not a WORD value */
      RecordLength <<= 16;         /* shift value to high WORD */
      RecordLength += GetWord(fp); /* read in LOW word value */
    }
  }

> 
>       Hans
> 

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/


Reply via email to