ftp.nice.ch/pub/next/tools/cdrom/pCD.0.34.N.bs.tar.gz#/pCD0.3.4/hpcdtoppm.0.4/output.c

This is output.c in view mode; [Download] [Up]

/* hpcdtoppm (Hadmut's pcdtoppm) v0.4
*  Copyright (c) 1992, 1993 by Hadmut Danisch (danisch@ira.uka.de).
*  Permission to use and distribute this software and its
*  documentation for noncommercial use and without fee is hereby granted,
*  provided that the above copyright notice appear in all copies and that
*  both that copyright notice and this permission notice appear in
*  supporting documentation. It is not allowed to sell this software in 
*  any way. This software is not public domain.
*/

#include "hpcdtoppm.h"



static void flip_corr(w,h,ptr,ystep,xstep)
  sdim w,h,*ystep,*xstep;
  uBYTE **ptr;
 {
  if(flvert) 
   { (*ptr) += (h-1)* (*ystep);
     (*ystep) = -(*ystep);
   }

  if(flhori)
   {(*ptr) += (w-1)* (*xstep);
    (*xstep) = -(*xstep);
   }
 }


static void call_1plane(proc,w,h, ptr,zeil,pix) 
  void (*proc)();
  sdim w,h, zeil,pix;
  uBYTE *ptr;
 {
  flip_corr(w,h,&ptr,&zeil,&pix);
  (*proc)(w,h,ptr,zeil,pix);
 }


static void do_1plane(proc,w,h,g,t)
  void (*proc)();
  dim w,h;
  implane *g;
  enum TURNS t;
 {
   switch(t)
    {case T_NONE: call_1plane(proc,w,h,g->im,g->mwidth,1);
                  break;
     case T_RIGHT:call_1plane(proc,h,w,g->im + g->mwidth * ( g->iheight - 1) , 1 , -(g->mwidth));
                  break;
     case T_LEFT: call_1plane(proc,h,w,g->im + g->iwidth - 1 , -1 , (g->mwidth));
                  break; 
     default:error(E_INTERN);
    }

 }



static void call_3plane(proc,w,h, rptr,rzeil,rpix,  
                               gptr,gzeil,gpix,  
                               bptr,bzeil,bpix) 
  void (*proc)();
  sdim w,h, rzeil,gzeil,bzeil, rpix,gpix,bpix;
  uBYTE *rptr,*gptr,*bptr;
 {
  flip_corr(w,h,&rptr,&rzeil,&rpix);
  flip_corr(w,h,&gptr,&gzeil,&gpix);
  flip_corr(w,h,&bptr,&bzeil,&bpix);

  (*proc)(w,h,rptr,rzeil,rpix,gptr,gzeil,gpix,bptr,bzeil,bpix );
 }


static void do_3plane(proc,w,h,r,g,b,t)
  void (*proc)();
  dim w,h;
  implane *r,*g,*b;
  enum TURNS t;
 {
   switch(t)
    {case T_NONE: call_3plane(proc,w,h,r->im,r->mwidth,1,
                                       g->im,g->mwidth,1,
                                       b->im,b->mwidth,1);
                  break;     
     case T_RIGHT:call_3plane(proc,h,w,r->im + r->mwidth * ( r->iheight - 1) , 1 , -(r->mwidth),
                                       g->im + g->mwidth * ( g->iheight - 1) , 1 , -(g->mwidth),
                                       b->im + b->mwidth * ( b->iheight - 1) , 1 , -(b->mwidth));
                  break;     
     case T_LEFT: call_3plane(proc,h,w,r->im + r->iwidth - 1 , -1 , (r->mwidth),
                                       g->im + g->iwidth - 1 , -1 , (g->mwidth),
                                       b->im + b->iwidth - 1 , -1 , (b->mwidth));
                              break;           
     default:error(E_INTERN);
    }

 }






void writepicture(w,h,r,g,b,t)
  dim w,h;
  implane *r,*g,*b;
  enum TURNS t;
 {

  melde("writepicture\n");
     if((!r) || (r->iwidth != w ) || (r->iheight != h) || (!r->im)) error(E_INTERN);
  
  if(!monochrome)
   {
     if((!g) || (g->iwidth != w ) || (g->iheight != h) || (!g->im)) error(E_INTERN);
     if((!b) || (b->iwidth != w ) || (b->iheight != h) || (!b->im)) error(E_INTERN);
   }

  switch(outfor)
   {case O_YCC:
    case O_PPM:  do_3plane(write_ppm     ,w,h,r,g,b,t); break;
    case O_PS:   do_3plane(write_psrgb   ,w,h,r,g,b,t); break;
    case O_EPS:  do_3plane(write_epsrgb  ,w,h,r,g,b,t); break;

    case O_PGM:  do_1plane(write_pgm     ,w,h,r,t);     break;
    case O_PSG:  do_1plane(write_psgrey  ,w,h,r,t);     break;
    case O_EPSG: do_1plane(write_epsgrey ,w,h,r,t);     break;

    default: error(E_INTERN);
   }


 }









struct ph1 
 {char  id1[8];
  uBYTE ww1[14];
  char  id2[20];
  char  id3[4*16+4];
  short ww2;
  char  id4[20];
  uBYTE ww3[2*16+1];
  char  id5[4*16];
  uBYTE idx[11*16];
 } ;


void druckeid()
{struct ph1 *d;
 char ss[100];

 d=(struct ph1 *)sbuffer;

#define dr(feld,kennung)   \
     strncpy(ss,feld,sizeof(feld));\
     ss[sizeof(feld)]=0;\
     fprintf(stderr,"%s: %s \n",kennung,ss);


dr(d->id1,"Id1")
dr(d->id2,"Id2")
dr(d->id3,"Id3")
dr(d->id4,"Id4")
dr(d->id5,"Id5")

#undef dr 

}






These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.