[comp.graphics] Wanted: ppmtoilbm for 24bit IFF

dean@coplex.uucp (Dean Brooks) (04/14/91)

    The PBM package is great for dealing with 24bit graphics, but
I have been desperately trying to find a ppmtoilbm that will
output in 24bit Amiga IFF format.

    I have all these wonderful raytraces that are in PBM format,
but I cant get them converted to 24bit IFF.  The PBM utilities
are great, because I can run them on our UNIX system at work
(much faster than on my Amiga).

 					Thanks...
--
dean@coplex.uucp (Dean Brooks)
Copper Electronics, Inc.
Louisville, Kentucky

marc@PostImage.COM (Marc Boucher) (04/21/91)

dean@coplex.uucp (Dean Brooks) writes:


>    The PBM package is great for dealing with 24bit graphics, but
>I have been desperately trying to find a ppmtoilbm that will
>output in 24bit Amiga IFF format.

>    I have all these wonderful raytraces that are in PBM format,
>but I cant get them converted to 24bit IFF.  The PBM utilities
>are great, because I can run them on our UNIX system at work
>(much faster than on my Amiga).

> 					Thanks...
>--
>dean@coplex.uucp (Dean Brooks)
>Copper Electronics, Inc.
>Louisville, Kentucky

I have tought IFF24 to ilbmtoppm. This lets you convert 24bit Amiga IFFs
to ppm: The opposite of what you are asking for.

But I plan to modify ppmtoilbm in the near future as well.

-Marc.

--
Marc Boucher                   Internet: marc@PostImage.COM      BIX: mboucher
Dir., Informatique             Telephone: (514) 489-8989         FAX: 489-0242
(H) PostImage Inc.             6265 St-Jacques O., Montreal QC Canada H4B 1T8


*** ilbmtoppm.c.ORIG	Sun Apr 21 09:39:21 1991
--- ilbmtoppm.c	Sun Apr 21 09:41:12 1991
***************
*** 1,5 ****
--- 1,7 ----
  /* ilbmtoppm.c - read an IFF ILBM file and produce a portable pixmap
  **
+ ** IFF24 (deep ilbm) support added by Marc Boucher <marc@PostImage.COM>
+ **
  ** Copyright (C) 1989 by Jef Poskanzer.
  **
  ** Permission to use, copy, modify, and distribute this software and its
***************
*** 23,29 ****
      short rows, cols = 0, row, col;
      int maxval;
      char iffid[5];
!     unsigned char *body = 0, *bp, *ubp, *rawrow, *runbuf;
      long formsize, bytesread, chunksize, viewportmodes = 0;
      int nPlanes, masking, compression, xAsp, yAsp, ham, hammask, allPlanes;
      unsigned char get_byte();
--- 25,32 ----
      short rows, cols = 0, row, col;
      int maxval;
      char iffid[5];
!     unsigned char *body = 0, *bp, *ubp, *runbuf;
!     unsigned long *rawrow;
      long formsize, bytesread, chunksize, viewportmodes = 0;
      int nPlanes, masking, compression, xAsp, yAsp, ham, hammask, allPlanes;
      unsigned char get_byte();
***************
*** 179,185 ****
      else
  	{
  	ham = 0;
! 	if ( colormap != 0 )
  	    maxval = 255;		/* colormap contains bytes */
  	else
  	    maxval = pm_bitstomaxval( nPlanes );
--- 182,188 ----
      else
  	{
  	ham = 0;
! 	if ( ( colormap != 0 ) || (nPlanes==24) )
  	    maxval = 255;		/* colormap contains bytes */
  	else
  	    maxval = pm_bitstomaxval( nPlanes );
***************
*** 204,210 ****
  	colormap = tempcolormap;
  	colors *= 2;
  	}
!     if ( colormap == 0 )
  	pm_message(
  	    "no colormap - interpreting values as grayscale", 0,0,0,0,0 );
      allPlanes = nPlanes + ( masking == mskHasMask ? 1 : 0 );
--- 207,213 ----
  	colormap = tempcolormap;
  	colors *= 2;
  	}
!     if ( ( colormap == 0 ) && ( nPlanes != 24 ) )
  	pm_message(
  	    "no colormap - interpreting values as grayscale", 0,0,0,0,0 );
      allPlanes = nPlanes + ( masking == mskHasMask ? 1 : 0 );
***************
*** 211,217 ****
  
      ppm_writeppminit( stdout, cols, rows, (pixval) maxval, 0 );
      pixelrow = ppm_allocrow( cols );
!     rawrow = (unsigned char *) malloc( cols );
      if ( rawrow == 0 )
  	pm_error( "out of memory", 0,0,0,0,0 );
      runbuf = (unsigned char *) malloc( RowBytes( cols ) );
--- 214,220 ----
  
      ppm_writeppminit( stdout, cols, rows, (pixval) maxval, 0 );
      pixelrow = ppm_allocrow( cols );
!     rawrow = (unsigned long *) malloc( cols*sizeof(unsigned long) );
      if ( rawrow == 0 )
  	pm_error( "out of memory", 0,0,0,0,0 );
      runbuf = (unsigned char *) malloc( RowBytes( cols ) );
***************
*** 303,309 ****
  		    pm_error( "impossible HAM code", 0,0,0,0,0 );
  		    }
  		}
! 	    else if ( colormap != 0 )
  		/* Non-HAM colormapped. */
  		pixelrow[col] = colormap[rawrow[col]];
  	    else
--- 306,313 ----
  		    pm_error( "impossible HAM code", 0,0,0,0,0 );
  		    }
  		}
! 	    else if(nPlanes==24) PPM_ASSIGN(pixelrow[col], rawrow[col]&0xff, (rawrow[col]&0xff00)>>8, (rawrow[col]&0xff0000)>>16);
! 	else if ( colormap != 0 )
  		/* Non-HAM colormapped. */
  		pixelrow[col] = colormap[rawrow[col]];
  	    else