Xref: utzoo comp.windows.x:15483 comp.graphics:8742 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!rutgers!mephisto!utkcs2!alphard!battle From: battle@alphard.cs.utk.edu (David Battle) Newsgroups: comp.windows.x,comp.graphics Subject: Re: New version of PBMPLUS released. Message-ID: <1419@utkcs2.cs.utk.edu> Date: 29 Nov 89 14:19:08 GMT References: <14701@well.UUCP> <1408@utkcs2.cs.utk.edu> Sender: news@utkcs2.cs.utk.edu Reply-To: battle@alphard.cs.utk.edu (David Battle) Followup-To: comp.windows.x Organization: CS Dept -- University of TN, Knoxville Lines: 55 In article <1408@utkcs2.cs.utk.edu> battle@alphard.cs.utk.edu (I) write: >I am having trouble using PBMPLUS on a DECstation 3100. In particular >I am trying to make a dump of a color (8 bits/pixel) window and change >it to a portable pixmap. Here is the error I get: > >battle> xwd | xwdtoppm > bitmap.out >xwdtoppm: unknown XWD file version: 117440512 > >I am using the version of xwd which came with the X.V11R3 distribution >from MIT. > >What am I doing wrong? > > -David Battle > battle@utkux1.utk.edu > battle@battle.esd.ornl.gov Note that 117440512 in hex is 07000000 and that the "correct" xwd version number is 7. Obviously a byte ordering problem. Oddly enough this particular bug seems to have resulted from a bug in DEC's optimizer (at least it went away when I removed -O from the CCFLAGS). I discovered another bug which appears to be with the code itself. In xwdtoppm.c around line 250 the code reads: /* Read X11 colormap. */ for ( i = 0; i < h11P->colormap_entries; i++ ) { if ( fread( &x11col, sizeof(X11XColor), 1, file ) != 1 ) pm_error( "couldn't read X11 XWD colormap", 0,0,0,0,0 ); /**** 1 ****/ if ( *maxvalP != 65535 ) { x11col.red = (long) x11col.red * *maxvalP / 65535; x11col.green = (long) x11col.green * *maxvalP / 65535; x11col.blue = (long) x11col.blue * *maxvalP / 65535; } PPM_ASSIGN( colors[x11col.pixel], x11col.red, x11col.green, x11col.blue ); } Most likely, the following code should be inserted at the line which I have marked /**** 1 ****/: if(byte_swap) { x11col.pixel = bs_long(x11col.pixel); x11col.red = bs_short(x11col.red); x11col.green = bs_short(x11col.green); x11col.blue = bs_short(x11col.blue); } This seems to have fixed the other problems I was having. -David Brought to you by Super Global Mega Corp .com