[comp.graphics] TARGA32 - PBM, patch included

pokey@well.UUCP (Jef Poskanzer) (10/17/89)

In the referenced message, tron1@tronsbox.UUCP (HIM) wrote:
}I have a bunch of TARGA32 images from a Sharp Color Scanner. I would like to
}see these files and fork with them in FUZZY.
}The tga2fbm converter I have seems to mess them up

The PBM+ package, distributed over alt.sources (beta version) a few weeks
ago, handles all documented variations of Targa formats.  And if you apply
the appended patch, it will even get the color order right. (The Targa spec
and the Targa hardware disagree on the order -- I went with the spec, and
got burned.)

PBM+ is also available via FTP as expo.lcs.mit.edu:contrib/pbmplus.tar.Z.

}In addition is there a "img8" to FBM converter available?

What is "img8"?

}If not , I* will have to do it after I finish the IFF/HAM - FBM converter in
}progress.

PBM+ includes an ILBM reader and writer, and both handle HAM.
---
Jef

    Jef Poskanzer  pokey@well.sf.ca.us  {ucbvax, apple, hplabs}!well!pokey
         "Don't say yes until I finish talking." -- Darryl F. Zanuck

*** t/pbmplus/ppm/tgatoppm.c	Wed Sep 13 23:59:49 1989
--- pbmplus/ppm/tgatoppm.c	Thu Sep 28 18:54:30 1989
***************
*** 41,47 ****
      unsigned int temp1, temp2;
      FILE *ifd;
      int argn, debug, rows, cols, row, col, realrow;
!     pixval maxval;
      pixel **pixels;
      char *usage = " [-debug] [tgafile]";
  
--- 41,47 ----
      unsigned int temp1, temp2;
      FILE *ifd;
      int argn, debug, rows, cols, row, col, realrow;
!     int maxval;
      pixel **pixels;
      char *usage = " [-debug] [tgafile]";
  
***************
*** 141,146 ****
--- 141,148 ----
  	    pm_error(
  		"unknown colormap pixel size - %d", tga_head.CoSize, 0,0,0,0 );
  	    }
+ 	if ( maxval > PPM_MAXMAXVAL )
+ 	    pm_error( "CoSize is too large - try recompiling with a larger pixval type" );
  	}
      else
  	{ /* Not colormap, so figure maxval from PixelSize. */
***************
*** 161,166 ****
--- 163,170 ----
  	    default:
  	    pm_error( "unknown pixel size - %d", tga_head.PixelSize, 0,0,0,0 );
  	    }
+ 	if ( maxval > PPM_MAXMAXVAL )
+ 	    pm_error( "PixelSize is too large - try recompiling with a larger pixval type" );
  	}
  
      /* If required, read the color map information. */
***************
*** 228,234 ****
  
      pm_close( ifd );
  
!     ppm_writeppm( stdout, pixels, cols, rows, maxval );
  
      exit( 0 );
      }
--- 232,238 ----
  
      pm_close( ifd );
  
!     ppm_writeppm( stdout, pixels, cols, rows, (pixval) maxval );
  
      exit( 0 );
      }
***************
*** 290,301 ****
  	b = j & 0x1F;
  	break;
  
! 	case 32:			/* Read alpha byte & throw away. */
! 	(void) getbyte( ifd );
! 	case 24:			/* 8 bits each of red green and blue. */
! 	r = getbyte( ifd );
! 	g = getbyte( ifd );
  	b = getbyte( ifd );
  	break;
  
  	default:
--- 294,306 ----
  	b = j & 0x1F;
  	break;
  
! 	case 32:
! 	case 24:			/* 8 bits each of blue green and red. */
  	b = getbyte( ifd );
+ 	g = getbyte( ifd );
+ 	r = getbyte( ifd );
+ 	if ( Size == 32 )
+ 	    (void) getbyte( ifd );	/* Read alpha byte & throw away. */
  	break;
  
  	default:
***************
*** 355,366 ****
  	Blu = j & 0x1F;
  	break;
  
! 	case 32:			/* Read alpha byte & throw away. */
! 	(void) getbyte( ifd );
! 	case 24:			/* 8 bits each of red green and blue. */
! 	Red = getbyte( ifd );
! 	Grn = getbyte( ifd );
  	Blu = getbyte( ifd );
  	l = 0;
  	break;
  
--- 360,372 ----
  	Blu = j & 0x1F;
  	break;
  
! 	case 32:
! 	case 24:			/* 8 bits each of blue green and red. */
  	Blu = getbyte( ifd );
+ 	Grn = getbyte( ifd );
+ 	Red = getbyte( ifd );
+ 	if ( Size == 32 )
+ 	    (void) getbyte( ifd );	/* Read alpha byte & throw away. */
  	l = 0;
  	break;