Article View: gnu.ghostscript.bug
Article #182Re: Drivers gifmono, pcxmono PROBLEM
From: Rodney Mcduff
Date: Tue, 04 Aug 1992 06:15
Date: Tue, 04 Aug 1992 06:15
82 lines
3659 bytes
3659 bytes
This is a case of BIG_ENDIAN and LITTLE_ENDIAN.
I believe the gif and pcx drivers work fine on a PC (they were probably written on a PC)
but on a 'real' machine it gives exactly the problems you mention ie byte swapping.
This fix is to the put the following
#if arch_is_big_endian == 1
header.width = ((header.width & 0x00ff)<<8) | ((header.width & 0xff00)>>8);
header.height = ((header.height & 0x00ff)<<8) | ((header.height &
#endif /* arch_is_big_endian == 1 */
just before the
/* Write the header. */
header.width = header.height = 0; /* debugging */
if ( fwrite(&header, 1, 13, file) < 13 )
{ code = gs_error_ioerror;
goto gif_done;
}
and
#if arch_is_big_endian == 1
header_desc.width = ((header_desc.width & 0x00ff)<<8) | ((header_desc.width & 0xff00)>>8);
header_desc.height = ((header_desc.height & 0x00ff)<<8) | ((header_desc.height & 0xff00)>>8);
#endif /* arch_is_big_endian == 1 */
just before the
/* Write the header image descriptor. */
fputc(0x2c,file); /* start with separator */
if ( fwrite(&header_desc, 1, 9, file) < 9 )
{ code = gs_error_ioerror;
goto gif_done;
}
in the file gdevgif.c.
Similar arrangement for the pcx stuff. Insert
#if arch_is_big_endian == 1
phdr->x2 = ((phdr->x2 & 0x00ff)<<8) | ((phdr->x2 & 0xff00)>>8);
phdr->y2 = ((phdr->y2 & 0x00ff)<<8) | ((phdr->y2 & 0xff00)>>8);
phdr->hres = ((phdr->hres & 0x00ff)<<8) | ((phdr->hres & 0xff00)>>8);
phdr->vres = ((phdr->vres & 0x00ff)<<8) | ((phdr->vres & 0xff00)>>8);
phdr->bpl = ((phdr->bpl & 0x00ff)<<8) | ((phdr->bpl & 0xff00)>>8);
phdr->palinfo = ((phdr->palinfo & 0x00ff)<<8) | ((phdr->palinfo & 0xff00)>>8);
#endif /* arch_is_big_endian == 1 */
just before
/* Write the header. */
if ( fwrite((const char *)phdr, 1, 128, file) < 128 )
{ code = gs_error_ioerror;
goto pcx_done;
}
Just make sure all the variables whose size are greater that 1 byte and that are written into
the gif (pcx) file are swapped. Hope this helps.
P.S. Isn't ghostscript great.
You should try ghostview (availiable at an archie near you)
--
+-------------------------+------------------------------------------+
| _ ^ _ | Rodney McDuff |
| |\ /|\ /| | Physics Department |
| \ | / | The University of Queensland |
| \ | / | St. Lucia, Brisbane |
| \|/ | Queensland, Australia. 4072. |
| <--------+--------> | |
| /|\ | TELEPHONE: +61 7 365 3424 |
| / | \ | INTERNET:mcduff@newton.physics.uq.oz.au |
| / | \ | FACSIMILE: +61 7 365 1242 |
| |/ \|/ \| | |
| - v - | |
+-------------------------+------------------------------------------+
Technical Details
Message-ID:
<1992Aug4.161547.15908@uqvax.cc.uq.oz.au>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!newton.PHysics.uq.oz.AU!mcduffReferences:
<1992Aug3.102502.24821@sun1.ruf.uni-freiburg.de>Show Full Headers
Complete Article Headers
Newsgroups: gnu.ghostscript.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!newton.PHysics.uq.oz.AU!mcduff From: mcduff@newton.PHysics.uq.oz.AU (Rodney Mcduff) Subject: Re: Drivers gifmono, pcxmono PROBLEM Message-ID: <1992Aug4.161547.15908@uqvax.cc.uq.oz.au> Sender: gnulists@ai.mit.edu Organization: Physics Dept. The University of Queensland References: <1992Aug3.102502.24821@sun1.ruf.uni-freiburg.de> Distribution: gnu Date: Tue, 4 Aug 1992 06:15:46 GMT Approved: bug-ghostscript@prep.ai.mit.edu Lines: 85