diff --git a/panda/src/pnm/Sources.pp b/panda/src/pnm/Sources.pp deleted file mode 100644 index b204623ad7..0000000000 --- a/panda/src/pnm/Sources.pp +++ /dev/null @@ -1,23 +0,0 @@ -#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ - dtoolutil:c dtoolbase:c dtool:m -#define LOCAL_LIBS pandabase - -#if $[or $[eq $[USE_COMPILER],MSVC],$[eq $[USE_COMPILER],INTEL]] - #define CFLAGS /D__STDC__ -#endif - -#begin lib_target - #define TARGET pnm - - #define SOURCES \ - bitio.c bitio.h compile.h libpbm.h libpbm1.c libpbm2.c libpbm3.c \ - libpbm4.c libpbm5.c libpgm.h libpgm1.c libpgm2.c libpnm1.c \ - libpnm2.c libpnm3.c libpnm4.c libppm.h libppm1.c libppm2.c \ - libppm3.c libppm4.c libppm5.c pbm.h pbmfont.h pbmplus.h pgm.h \ - pnm.h ppm.h ppmcmap.h ppmdraw.h rast.h version.h - - #define INSTALL_HEADERS \ - pbm.h pbmplus.h pgm.h pnm.h ppm.h - -#end lib_target - diff --git a/panda/src/pnm/compile.h b/panda/src/pnm/compile.h deleted file mode 100644 index 9b3d47b599..0000000000 --- a/panda/src/pnm/compile.h +++ /dev/null @@ -1,4 +0,0 @@ -/* compile_time.h This file tells the package when it was compiled */ -/* DO NOT EDIT - THIS FILE IS MAINTAINED AUTOMATICALLY */ -#define COMPILE_TIME "Tue Mar 19 19:03:20 PST 1996" -#define COMPILED_BY "drose" diff --git a/panda/src/pnm/libpbm.h b/panda/src/pnm/libpbm.h deleted file mode 100644 index a11c888f8c..0000000000 --- a/panda/src/pnm/libpbm.h +++ /dev/null @@ -1,17 +0,0 @@ -/* libpbm.h - internal header file for libpbm portable bitmap library -*/ - -#ifndef _LIBPBM_H_ -#define _LIBPBM_H_ - -/* Here are some routines internal to the pbm library. */ - -char pbm_getc ARGS(( FILE* file )); -unsigned char pbm_getrawbyte ARGS(( FILE* file )); -int pbm_getint ARGS(( FILE* file )); - -int pbm_readmagicnumber ARGS(( FILE* file )); - -EXPCL_PANDA void pbm_readpbminitrest( FILE* file, int* colsP, int* rowsP ); - -#endif /*_LIBPBM_H_*/ diff --git a/panda/src/pnm/libpbm1.c b/panda/src/pnm/libpbm1.c deleted file mode 100644 index 956057af23..0000000000 --- a/panda/src/pnm/libpbm1.c +++ /dev/null @@ -1,1549 +0,0 @@ -/* libpbm1.c - pbm utility library part 1 -** -** Copyright (C) 1988 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include - -#include "pbm.h" -#include "version.h" -#include "compile.h" -#include "libpbm.h" -#if defined(__STDC__) || defined(WIN32_VC) -#include -#else /*__STDC__*/ -#include -#endif /*__STDC__*/ - -/* Assume we have strerror() available. */ -#define A_STRERROR - - -/* Variable-sized arrays. */ - -char* -pm_allocrow( cols, size ) - int cols; - int size; - { - register char* itrow; - - itrow = (char*) malloc( cols * size ); - if ( itrow == (char*) 0 ) - pm_error( "out of memory allocating a row" ); - return itrow; - } - -void -pm_freerow( itrow ) - char* itrow; - { - free( itrow ); - } - - -#ifndef A_FRAGARRAY -char** -pm_allocarray( cols, rows, size ) - int cols, rows; - int size; - { - char** its; - int i; - - its = (char**) malloc( rows * sizeof(char*) ); - if ( its == (char**) 0 ) - pm_error( "out of memory allocating an array" ); - its[0] = (char*) malloc( rows * cols * size ); - if ( its[0] == (char*) 0 ) - pm_error( "out of memory allocating an array" ); - for ( i = 1; i < rows; ++i ) - its[i] = &(its[0][i * cols * size]); - return its; - } - -void -pm_freearray( its, rows ) - char** its; - int rows; - { - free( its[0] ); - free( its ); - } -#else /* A_FRAGARRAY */ -char** -pm_allocarray( cols, rows, size ) - int cols, rows; - int size; - { - char** its; - int i; - its = (char**) malloc( (rows + 1) * sizeof(char*) ); - if ( its == (char**) 0 ) - pm_error( "out of memory allocating an array" ); - its[rows] = its[0] = (char*) malloc( rows * cols * size ); - if ( its[0] != (char*) 0 ) - for ( i = 1; i < rows; ++i ) - its[i] = &(its[0][i * cols * size]); - else - for( i = 0; i < rows; ++i ) - its[i] = pm_allocrow( cols, size ); - return its; - } -void -pm_freearray( its, rows ) - char** its; - int rows; - { - int i; - if( its[rows] != (char*) 0 ) - free( its[rows] ); - else - for( i = 0; i < rows; ++i ) - pm_freerow( its[i] ); - free( its ); - } -#endif /* A_FRAGARRAY */ - - -/* Case-insensitive keyword matcher. */ - -int -pm_keymatch( str, keyword, minchars ) - char* str; - char* keyword; - int minchars; - { - register int len; - - len = strlen( str ); - if ( len < minchars ) - return 0; - while ( --len >= 0 ) - { - register char c1, c2; - - c1 = *str++; - c2 = *keyword++; - if ( c2 == '\0' ) - return 0; - if ( isupper( c1 ) ) - c1 = tolower( c1 ); - if ( isupper( c2 ) ) - c1 = tolower( c2 ); - if ( c1 != c2 ) - return 0; - } - return 1; - } - - -/* Log base two hacks. */ - -int -pm_maxvaltobits( maxval ) - int maxval; - { - if ( maxval <= 1 ) - return 1; - else if ( maxval <= 3 ) - return 2; - else if ( maxval <= 7 ) - return 3; - else if ( maxval <= 15 ) - return 4; - else if ( maxval <= 31 ) - return 5; - else if ( maxval <= 63 ) - return 6; - else if ( maxval <= 127 ) - return 7; - else if ( maxval <= 255 ) - return 8; - else if ( maxval <= 511 ) - return 9; - else if ( maxval <= 1023 ) - return 10; - else if ( maxval <= 2047 ) - return 11; - else if ( maxval <= 4095 ) - return 12; - else if ( maxval <= 8191 ) - return 13; - else if ( maxval <= 16383 ) - return 14; - else if ( maxval <= 32767 ) - return 15; - else if ( (long) maxval <= 65535L ) - return 16; - else - pm_error( "maxval of %d is too large!", maxval ); - return 0; /* just to make compiler happy; can't get here. */ - } - -int -pm_bitstomaxval( bits ) - int bits; - { - return ( 1 << bits ) - 1; - } - - -/* Initialization. */ - -static char* progname; -static int showmessages; - -void -pm_init( argcP, argv ) - int* argcP; - char* argv[]; - { - int argn, i; -#ifdef A_RGBENV - char *rgbdef; -#endif /* A_RGBENV */ - -#ifndef VMS - /* Extract program name. */ - progname = rindex( argv[0], '/'); -#else -{ char **temp_argv = argv; - int old_argc = *argcP; - int i; - getredirection( argcP, &temp_argv ); - if (*argcP > old_argc) { - /* Number of command line arguments has increased */ - fprintf( stderr, "Sorry!! getredirection() for VMS has changed the argument list!!!\n"); - fprintf( stderr, "This is intolerable at the present time, so we must stop!!!\n"); - exit(1); - } - for (i=0; i<*argcP; i++) - argv[i] = temp_argv[i]; - } - if ( progname == NULL ) progname = rindex( argv[0], ']'); - if ( progname == NULL ) progname = rindex( argv[0], '>'); -#endif - if ( progname == NULL ) - progname = argv[0]; - else - ++progname; - - /* Check for any global args. */ - showmessages = 1; - for ( argn = 1; argn < *argcP; ++argn ) - { - if ( pm_keymatch( argv[argn], "-quiet", 6 ) ) - { - showmessages = 0; - } - else if ( pm_keymatch( argv[argn], "-version", 7 ) ) - { - pm_message( "Version: %s", PBMPLUS_VERSION ); -#if defined(COMPILE_TIME) && defined(COMPILED_BY) - pm_message( "Compiled %s by user \"%s\"", - COMPILE_TIME, COMPILED_BY ); -#endif -#ifdef BSD - pm_message( "BSD defined" ); -#endif /*BSD*/ -#ifdef SYSV -#ifdef VMS - pm_message( "VMS & SYSV defined" ); -#else - pm_message( "SYSV defined" ); -#endif -#endif /*SYSV*/ -#ifdef MSDOS - pm_message( "MSDOS defined" ); -#endif /*MSDOS*/ -#ifdef AMIGA - pm_message( "AMIGA defined" ); -#endif /* AMIGA */ -#ifdef PBMPLUS_RAWBITS - pm_message( "PBMPLUS_RAWBITS defined" ); -#endif /*PBMPLUS_RAWBITS*/ -#ifdef PBMPLUS_BROKENPUTC1 - pm_message( "PBMPLUS_BROKENPUTC1 defined" ); -#endif /*PBMPLUS_BROKENPUTC1*/ -#ifdef PBMPLUS_BROKENPUTC2 - pm_message( "PBMPLUS_BROKENPUTC2 defined" ); -#endif /*PBMPLUS_BROKENPUTC2*/ -#ifdef PGM_BIGGRAYS - pm_message( "PGM_BIGGRAYS defined" ); -#endif /*PGM_BIGGRAYS*/ -#ifdef PPM_PACKCOLORS - pm_message( "PPM_PACKCOLORS defined" ); -#endif /*PPM_PACKCOLORS*/ -#ifdef DEBUG - pm_message( "DEBUG defined" ); -#endif /*DEBUG*/ -#ifdef NEED_VFPRINTF1 - pm_message( "NEED_VFPRINTF1 defined" ); -#endif /*NEED_VFPRINTF1*/ -#ifdef NEED_VFPRINTF2 - pm_message( "NEED_VFPRINTF2 defined" ); -#endif /*NEED_VFPRINTF2*/ -#ifdef RGB_DB -#ifndef A_RGBENV - pm_message( "RGB_DB=\"%s\"", RGB_DB ); -#else /* A_RGBENV */ - if( rgbdef = getenv(RGB_DB) ) - pm_message( "RGB_DB= Env-var %s (set to \"%s\")", RGB_DB, rgbdef ); - else - pm_message( "RGB_DB= Env-var %s (unset)", RGB_DB ); -#endif /* A_RGBENV */ -#endif /*RGB_DB*/ -#ifdef LIBTIFF - pm_message( "LIBTIFF defined" ); -#endif /*LIBTIFF*/ - exit( 0 ); - } - else - continue; - for ( i = argn + 1; i <= *argcP; ++i ) - argv[i - 1] = argv[i]; - --(*argcP); - } - } - -void -pbm_init( argcP, argv ) - int* argcP; - char* argv[]; - { - pm_init( argcP, argv ); - } - - -/* Error handling. */ - -void -pm_usage( usage ) - char* usage; - { - fprintf( stderr, "usage: %s %s\n", progname, usage ); - exit( 1 ); - } - -void -pm_perror( reason ) - char* reason; - { -#ifndef A_STRERROR - extern char* sys_errlist[]; -#endif /* A_STRERROR */ - extern int errno; - char* e; - -#ifdef A_STRERROR - e = strerror(errno); -#else /* A_STRERROR */ - e = sys_errlist[errno]; -#endif /* A_STRERROR */ - - if ( reason != 0 && reason[0] != '\0' ) - pm_error( "%s - %s", reason, e ); - else - pm_error( "%s", e ); - } - -#if defined(__STDC__) || defined(WIN32_VC) -void -pm_message( char* format, ... ) - { - va_list args; - - va_start( args, format ); -#else /*__STDC__*/ -/*VARARGS1*/ -void -pm_message( va_alist ) - va_dcl - { /*}*/ - va_list args; - char* format; - - va_start( args ); - format = va_arg( args, char* ); -#endif /*__STDC__*/ - - if ( showmessages ) - { - fprintf( stderr, "%s: ", progname ); - (void) vfprintf( stderr, format, args ); - fputc( '\n', stderr ); - } - va_end( args ); - } - -#if defined(__STDC__) || defined(WIN32_VC) -void -pm_error( char* format, ... ) - { - va_list args; - - va_start( args, format ); -#else /*__STDC__*/ -/*VARARGS1*/ -void -pm_error( va_alist ) - va_dcl - { /*}*/ - va_list args; - char* format; - - va_start( args ); - format = va_arg( args, char* ); -#endif /*__STDC__*/ - - fprintf( stderr, "%s: ", progname ); - (void) vfprintf( stderr, format, args ); - fputc( '\n', stderr ); - va_end( args ); - exit( 1 ); - } - -#ifdef NEED_VFPRINTF1 - -/* Micro-vfprintf, for systems that don't have vfprintf but do have _doprnt. -*/ - -int -vfprintf( stream, format, args ) - FILE* stream; - char* format; - va_list args; - { - return _doprnt( format, args, stream ); - } -#endif /*NEED_VFPRINTF1*/ - -#ifdef NEED_VFPRINTF2 - -/* Portable mini-vfprintf, for systems that don't have either vfprintf or -** _doprnt. This depends only on fprintf. If you don't have fprintf, -** you might consider getting a new stdio library. -*/ - -int -vfprintf( stream, format, args ) - FILE* stream; - char* format; - va_list args; - { - int n; - char* ep; - char fchar; - char tformat[512]; - int do_long; - int i; - long l; - unsigned u; - unsigned long ul; - char* s; - double d; - - n = 0; - while ( *format != '\0' ) - { - if ( *format != '%' ) - { /* Not special, just write out the char. */ - (void) putc( *format, stream ); - ++n; - ++format; - } - else - { - do_long = 0; - ep = format + 1; - - /* Skip over all the field width and precision junk. */ - if ( *ep == '-' ) - ++ep; - if ( *ep == '0' ) - ++ep; - while ( isdigit( *ep ) ) - ++ep; - if ( *ep == '.' ) - { - ++ep; - while ( isdigit( *ep ) ) - ++ep; - } - if ( *ep == '#' ) - ++ep; - if ( *ep == 'l' ) - { - do_long = 1; - ++ep; - } - - /* Here's the field type. Extract it, and copy this format - ** specifier to a temp string so we can add an end-of-string. - */ - fchar = *ep; - (void) strncpy( tformat, format, ep - format + 1 ); - tformat[ep - format + 1] = '\0'; - - /* Now do a one-argument fprintf with the format string we have - ** isolated. - */ - switch ( fchar ) - { - case 'd': - if ( do_long ) - { - l = va_arg( args, long ); - n += fprintf( stream, tformat, l ); - } - else - { - i = va_arg( args, int ); - n += fprintf( stream, tformat, i ); - } - break; - - case 'o': - case 'x': - case 'X': - case 'u': - if ( do_long ) - { - ul = va_arg( args, unsigned long ); - n += fprintf( stream, tformat, ul ); - } - else - { - u = va_arg( args, unsigned ); - n += fprintf( stream, tformat, u ); - } - break; - - case 'c': - i = (char) va_arg( args, int ); - n += fprintf( stream, tformat, i ); - break; - - case 's': - s = va_arg( args, char* ); - n += fprintf( stream, tformat, s ); - break; - - case 'e': - case 'E': - case 'f': - case 'g': - case 'G': - d = va_arg( args, double ); - n += fprintf( stream, tformat, d ); - break; - - case '%': - (void) putc( '%', stream ); - ++n; - break; - - default: - return -1; - } - - /* Resume formatting on the next character. */ - format = ep + 1; - } - } - return nc; - } -#endif /*NEED_VFPRINTF2*/ - -#ifdef NEED_STRSTR -/* for systems which do not provide strstr */ -char* -strstr(s1, s2) - char *s1, *s2; -{ - int ls2 = strlen(s2); - - if (ls2 == 0) - return (s1); - while (strlen(s1) >= ls2) { - if (strncmp(s1, s2, ls2) == 0) - return (s1); - s1++; - } - return (0); -} - -#endif /*NEED_STRSTR*/ - - -/* File open/close that handles "-" as stdin and checks errors. */ - -FILE* -pm_openr( name ) - char* name; - { - FILE* f; - - if ( strcmp( name, "-" ) == 0 ) - f = stdin; - else - { -#ifndef VMS - f = fopen( name, "rb" ); -#else - f = fopen ( name, "r", "ctx=stm" ); -#endif - if ( f == NULL ) - { - pm_perror( name ); - exit( 1 ); - } - } - return f; - } - -FILE* -pm_openw( name ) - char* name; - { - FILE* f; - -#ifndef VMS - f = fopen( name, "wb" ); -#else - f = fopen ( name, "w", "mbc=32", "mbf=2" ); /* set buffer factors */ -#endif - if ( f == NULL ) - { - pm_perror( name ); - exit( 1 ); - } - return f; - } - -void -pm_close( f ) - FILE* f; - { - fflush( f ); - if ( ferror( f ) ) - pm_message( "a file read or write error occurred at some point" ); - if ( f != stdin ) - if ( fclose( f ) != 0 ) - pm_perror( "fclose" ); - } - -/* Endian I/O. -*/ - -int -pm_readbigshort( in, sP ) - FILE* in; - short* sP; - { - int c; - - if ( (c = getc( in )) == EOF ) - return -1; - *sP = ( c & 0xff ) << 8; - if ( (c = getc( in )) == EOF ) - return -1; - *sP |= c & 0xff; - return 0; - } - -#if __STDC__ -int -pm_writebigshort( FILE* out, short s ) -#else /*__STDC__*/ -int -pm_writebigshort( out, s ) - FILE* out; - short s; -#endif /*__STDC__*/ - { - (void) putc( ( s >> 8 ) & 0xff, out ); - (void) putc( s & 0xff, out ); - return 0; - } - -int -pm_readbiglong( in, lP ) - FILE* in; - long* lP; - { - int c; - - if ( (c = getc( in )) == EOF ) - return -1; - *lP = ( c & 0xff ) << 24; - if ( (c = getc( in )) == EOF ) - return -1; - *lP |= ( c & 0xff ) << 16; - if ( (c = getc( in )) == EOF ) - return -1; - *lP |= ( c & 0xff ) << 8; - if ( (c = getc( in )) == EOF ) - return -1; - *lP |= c & 0xff; - return 0; - } - -int -pm_writebiglong( out, l ) - FILE* out; - long l; - { - (void) putc( ( l >> 24 ) & 0xff, out ); - (void) putc( ( l >> 16 ) & 0xff, out ); - (void) putc( ( l >> 8 ) & 0xff, out ); - (void) putc( l & 0xff, out ); - return 0; - } - -int -pm_readlittleshort( in, sP ) - FILE* in; - short* sP; - { - int c; - - if ( (c = getc( in )) == EOF ) - return -1; - *sP = c & 0xff; - if ( (c = getc( in )) == EOF ) - return -1; - *sP |= ( c & 0xff ) << 8; - return 0; - } - -#if defined(__STDC__) || defined(WIN32_VC) -int -pm_writelittleshort( FILE* out, short s ) -#else /*__STDC__*/ -int -pm_writelittleshort( out, s ) - FILE* out; - short s; -#endif /*__STDC__*/ - { - (void) putc( s & 0xff, out ); - (void) putc( ( s >> 8 ) & 0xff, out ); - return 0; - } - -int -pm_readlittlelong( in, lP ) - FILE* in; - long* lP; - { - int c; - - if ( (c = getc( in )) == EOF ) - return -1; - *lP = c & 0xff; - if ( (c = getc( in )) == EOF ) - return -1; - *lP |= ( c & 0xff ) << 8; - if ( (c = getc( in )) == EOF ) - return -1; - *lP |= ( c & 0xff ) << 16; - if ( (c = getc( in )) == EOF ) - return -1; - *lP |= ( c & 0xff ) << 24; - return 0; - } - -int -pm_writelittlelong( out, l ) - FILE* out; - long l; - { - (void) putc( l & 0xff, out ); - (void) putc( ( l >> 8 ) & 0xff, out ); - (void) putc( ( l >> 16 ) & 0xff, out ); - (void) putc( ( l >> 24 ) & 0xff, out ); - return 0; - } - - -/* Read a file of unknown size to a buffer. Return the number of bytes - read. Allocate more memory as we need it. The calling routine has - to free() the buffer. - - Oliver Trepte, oliver@fysik4.kth.se, 930613 */ - -#define PM_BUF_SIZE 16384 /* First try this size of the buffer, then - double this until we reach PM_MAX_BUF_INC */ -#define PM_MAX_BUF_INC 65536 /* Don't allocate more memory in larger blocks - than this. */ - -char *pm_read_unknown_size( file, nread ) - FILE* file; - long* nread; -{ - long nalloc; - register int val; - char* buf; - - *nread = 0; - if ((buf=malloc(PM_BUF_SIZE)) == NULL) - pm_error("Cannot allocate memory"); - nalloc = PM_BUF_SIZE; - - while(1) { - if (*nread >= nalloc) { /* We need a larger buffer */ - if (nalloc > PM_MAX_BUF_INC) - nalloc += PM_MAX_BUF_INC; - else - nalloc += nalloc; - if ((buf=realloc(buf, nalloc)) == NULL) - pm_error("Cannot allocate %d bytes of memory", nalloc); - } - - if ((val = getc(file)) == EOF) - return (buf); - - buf[(*nread)++] = val; - } -} - -/*****************************************************************************/ - -#ifdef VMS -/* - * @(#)argproc.c 1.0 89/02/01 Mark Pizzolato (mark@infopiz.uucp) - */ - -#ifndef lint -char argproc_version[] = "@(#)argproc.c VMS uucp Version infopiz-1.0"; -#endif - -#include "includes.h" /* System include files, system dependent */ - - -/* - * getredirection() is intended to aid in porting C programs - * to VMS (Vax-11 C) which does not support '>' and '<' - * I/O redirection, along with a command line pipe mechanism - * using the '|' AND background command execution '&'. - * The piping mechanism will probably work with almost any 'filter' type - * of program. With suitable modification, it may useful for other - * portability problems as well. - * - * Author: Mark Pizzolato mark@infopiz.UUCP - */ -struct list_item - { - struct list_item *next; - char *value; - }; - -int -getredirection(ac, av) -int *ac; -char ***av; -/* - * Process vms redirection arg's. Exit if any error is seen. - * If getredirection() processes an argument, it is erased - * from the vector. getredirection() returns a new argc and argv value. - * In the event that a background command is requested (by a trailing "&"), - * this routine creates a background subprocess, and simply exits the program. - * - * Warning: do not try to simplify the code for vms. The code - * presupposes that getredirection() is called before any data is - * read from stdin or written to stdout. - * - * Normal usage is as follows: - * - * main(argc, argv) - * int argc; - * char *argv[]; - * { - * getredirection(&argc, &argv); - * } - */ -{ - int argc = *ac; /* Argument Count */ - char **argv = *av; /* Argument Vector */ - char *ap; /* Argument pointer */ - int j; /* argv[] index */ - extern int errno; /* Last vms i/o error */ - int item_count = 0; /* Count of Items in List */ - int new_file; /* flag, true if '>' used */ - struct list_item *list_head = 0; /* First Item in List */ - struct list_item *list_tail; /* Last Item in List */ - char *in = NULL; /* Input File Name */ - char *out = NULL; /* Output File Name */ - char *outmode = "w"; /* Mode to Open Output File */ - int cmargc = 0; /* Piped Command Arg Count */ - char **cmargv = NULL;/* Piped Command Arg Vector */ - stat_t statbuf; /* fstat buffer */ - - /* - * First handle the case where the last thing on the line ends with - * a '&'. This indicates the desire for the command to be run in a - * subprocess, so we satisfy that desire. - */ - ap = argv[argc-1]; - if (0 == strcmp("&", ap)) - exit(background_process(--argc, argv)); - if ('&' == ap[strlen(ap)-1]) - { - ap[strlen(ap)-1] = '\0'; - exit(background_process(argc, argv)); - } - /* - * Now we handle the general redirection cases that involve '>', '>>', - * '<', and pipes '|'. - */ - for (new_file = 0, j = 0; j < argc; ++j) - { - if (0 == strcmp("<", argv[j])) - { - if (j+1 >= argc) - { - errno = EINVAL; - perror("No input file"); - exit(EXIT_ERR); - } - in = argv[++j]; - continue; - } - if ('<' == *(ap = argv[j])) - { - in = 1 + ap; - continue; - } - if (0 == strcmp(">", ap)) - { - if (j+1 >= argc) - { - errno = EINVAL; - perror("No output file"); - exit(EXIT_ERR); - } - out = argv[++j]; - new_file = 1; - continue; - } - if ('>' == *ap) - { - if ('>' == ap[1]) - { - outmode = "a"; - if ('\0' == ap[2]) - out = argv[++j]; - else - out = 2 + ap; - } - else - { out = 1 + ap; new_file = 1; } - continue; - } - if (0 == strcmp("|", argv[j])) - { - if (j+1 >= argc) - { - errno = EPIPE; - perror("No command to Pipe to"); - exit(EXIT_ERR); - } - cmargc = argc-(j+1); - cmargv = &argv[j+1]; - argc = j; - outmode = "wb"; /* pipes are binary mode devices */ - continue; - } - if ('|' == *(ap = argv[j])) - { - ++argv[j]; - cmargc = argc-j; - cmargv = &argv[j]; - argc = j; - outmode = "wb"; /* pipes are binary mode devices */ - continue; - } - expand_wild_cards(ap, &list_head, &list_tail, &item_count); - } - /* - * Allocate and fill in the new argument vector, Some Unix's terminate - * the list with an extra null pointer. - */ - argv = *av = calloc(item_count+1, sizeof(char *)); - for (j = 0; j < item_count; ++j, list_head = list_head->next) - argv[j] = list_head->value; - *ac = item_count; - if (cmargv != NULL) - { - char subcmd[1024]; - static char *pipe_and_fork(); - - if (out != NULL) - { - errno = EINVAL; - perror("Invalid '|' and '>' specified"); - exit(EXIT_ERR); - } - strcpy(subcmd, cmargv[0]); - for (j = 1; j < cmargc; ++j) - { - strcat(subcmd, " \""); - strcat(subcmd, cmargv[j]); - strcat(subcmd, "\""); - } - out = pipe_and_fork(subcmd); - outmode = "wb"; - } - - /* Check for input from a pipe (mailbox) */ - - if(fstat(0, &statbuf) == 0){ - if(strncmp(statbuf.st_dev, "MB", 2) == 0 || - strncmp(statbuf.st_dev, "_MB", 3) == 0){ - - /* Input from a pipe, reopen it in binary mode to disable */ - /* carriage control processing. */ - - if (in != NULL){ - errno = EINVAL; - perror("Invalid '|' and '<' specified"); - exit(EXIT_ERR); - } - freopen(statbuf.st_dev, "rb", stdin); - } - } - else { - perror("fstat failed"); - exit(EXIT_ERR); - } - -#ifdef __ALPHA - /*, "mbc=32", "mbf=2"))) blows up on the ALPHA cbm 11/08/92 */ - if ((in != NULL) && (NULL == freopen(in, "r", stdin))) - { -#else - if ((in != NULL) && (NULL == freopen(in, "r", stdin, "mbc=32", "mbf=2"))) - { -#endif - perror(in); /* Can't find file */ - exit(EXIT_ERR); /* Is a fatal error */ - } -#ifdef __ALPHA - if ((out != NULL) && (NULL == freopen(out, outmode, stdout))) - { -#else - if ((out != NULL) && (NULL == freopen(out, outmode, stdout, "mbc=32", "mbf=2"))) - { -#endif - perror(ap); /* Error, can't write or append */ - exit(EXIT_ERR); /* Is a fatal error */ - } - - if ( new_file ) { - /* - * We are making an explicit output file, fstat the file and - * declare exit handler to be able change the file to fixed length - * records if necessary. - */ - char fname[256]; - static int outfile_rundown(), check_outfile_filetype(); - static stat_t ofile_stat; - static struct exit_control_block { - struct exit_control_block *flink; - int (*exit_routine)(); - int arg_count; - int *status_address; /* arg 1 */ - stat_t *stat; /* arg 2 */ - int exit_status; - int skew[128]; - } exit_block = - { 0, outfile_rundown, 2, &exit_block.exit_status, &ofile_stat, 0 }; - - if ( fstat ( fileno(stdout), &ofile_stat ) == 0 ) - sys$dclexh ( &exit_block ); - else fprintf(stderr,"Error fstating stdout - %s\n", - strerror(errno,vaxc$errno) ); - - if ( fgetname ( stdout, fname, 0 ) ) check_outfile_filetype ( fname ); - } -#ifdef DEBUG - fprintf(stderr, "Arglist:\n"); - for (j = 0; j < *ac; ++j) - fprintf(stderr, "argv[%d] = '%s'\n", j, argv[j]); -#endif -} - -static int binary_outfile = 0; -void set_outfile_binary() { binary_outfile = 1; return; } - -/* - * Check if output file should be set to binary (fixed 512) on exit based - * upon the filetype. - */ -static int check_outfile_filetype ( name ) - char *name; -{ - char *binary_filetypes, *ext, *p, *t; - binary_filetypes = (char *) getenv ( "PBM_BINARY_FILETYPES" ); - if ( binary_filetypes == NULL ) return 0; - - ext = strchr ( name, '.' ); if ( ext == NULL ) return 0; - ext++; - t = strrchr ( name, '.' ); if ( t != NULL ) *t = '\0'; - - for ( p = binary_filetypes; *p != '\0'; p++ ) { - for ( t = p; - (*p != '\0' ) && (strchr ( ", ", *p ) == NULL); - p++ ) *p = toupper(*p); - *p = '\0'; - - if ( strcmp ( t, ext ) == 0 ) { - binary_outfile = 1; - break; - } - } - return binary_outfile; -} - - -/* - * Exit handler to set output file to binary on image exit. - */ -static int outfile_rundown ( reason, statbuf ) - int *reason; - stat_t *statbuf; -{ - int code, channel, status, LIB$GETDVI(), sys$assign(), sys$qiow(); - long int fib_desc[2], devchar; - short int iosb[4]; - $DESCRIPTOR(device, statbuf->st_dev); - struct fibdef fib; /* File information block (XQP) */ - struct atrdef atr[2]; - struct fat { - unsigned char rtype, ratattrib; - unsigned short int rsize, hiblk[2], efblk[2], ffbyte, maxrec, defext, gbc; - unsigned short int reserved[4], versions; - } rat; - - if ( !binary_outfile ) return 1; /* leave file alone */ - /* - * Assign channel to device listed in stat block and test if it is - * a directory structured device, returning if not. - */ - device.dsc$w_length = strlen ( statbuf->st_dev ); - status = sys$assign ( &device, &channel, 0, 0 ); - if ((status & 1) == 0) { fprintf(stderr, - "assign error to %s (%d)\n", device.dsc$a_pointer, status); - return status; } - code = DVI$_DEVCHAR; - status = LIB$GETDVI ( &code, &channel, 0, &devchar ); - if ((status & 1) == 0) { fprintf(stderr, "getdvi error: %d\n", status); - return status; } - if ( (devchar & DEV$M_DIR) == 0 ) return 1; - /* - * Build File Information Block and Atrribute block. - */ -#ifdef __ALPHA - fib.fib$w_fid[0] = statbuf->st_ino[0]; - fib.fib$w_fid[1] = statbuf->st_ino[1]; - fib.fib$w_fid[2] = statbuf->st_ino[2]; -#else - fib.fib$r_fid_overlay.fib$w_fid[0] = statbuf->st_ino[0]; - fib.fib$r_fid_overlay.fib$w_fid[1] = statbuf->st_ino[1]; - fib.fib$r_fid_overlay.fib$w_fid[2] = statbuf->st_ino[2]; -#endif - - atr[0].atr$w_size = sizeof(rat); - atr[0].atr$w_type = ATR$C_RECATTR; - atr[0].atr$l_addr = &rat; - atr[1].atr$w_size = 0; atr[1].atr$w_type = 0; - /* - * Perform access function with read_attributes sub-function. - */ - freopen ( "SYS$OUTPUT:", "a", stdout ); - fib_desc[0] = 10; fib_desc[1] = (long int) &fib; -#ifdef __ALPHA - fib.fib$l_acctl = FIB$M_WRITE; -#else - fib.fib$r_acctl_overlay.fib$l_acctl = FIB$M_WRITE; -#endif - status = sys$qiow ( 0, channel, IO$_ACCESS|IO$M_ACCESS, - &iosb, 0, 0, &fib_desc, 0, 0, 0, &atr, 0 ); - /* - * If status successful, update record byte and perform a MODIFY. - */ - if ( (status&1) == 1 ) status = iosb[0]; - if ( (status&1) == 1 ) { - rat.rtype = 1; /* fixed length records */ - rat.rsize = 512; /* 512 byte block recrods */ - rat.ratattrib = 0; /* Record attributes: none */ - - status = sys$qiow - ( 0, channel, IO$_MODIFY, &iosb, 0, 0, &fib_desc, 0, 0, 0, &atr, 0 ); - if ( (status&1) == 1 ) status = iosb[0]; - } - sys$dassgn ( channel ); - if ( (status & 1) == 0 ) fprintf ( stderr, - "Failed to convert output file to binary format, status: %d\n", status); - return status; -} - - -static add_item(head, tail, value, count) -struct list_item **head; -struct list_item **tail; -char *value; -int *count; -{ - if (*head == 0) - { - if (NULL == (*head = calloc(1, sizeof(**head)))) - { - errno = ENOMEM; - perror(""); - exit(EXIT_ERR); - } - *tail = *head; - } - else - if (NULL == ((*tail)->next = calloc(1, sizeof(**head)))) - { - errno = ENOMEM; - perror(""); - exit(EXIT_ERR); - } - else - *tail = (*tail)->next; - (*tail)->value = value; - ++(*count); -} - -static expand_wild_cards(item, head, tail, count) -char *item; -struct ltem_list **head; -struct ltem_list **tail; -int *count; -{ -int expcount = 0; -int context = 0; -int status; -int status_value; -int had_version; -$DESCRIPTOR(filespec, item); -$DESCRIPTOR(defaultspec, "SYS$DISK:[]*.*;"); -$DESCRIPTOR(resultspec, ""); - - if (strcspn(item, "*%") == strlen(item)) - { - add_item(head, tail, item, count); - return; - } - resultspec.dsc$b_dtype = DSC$K_DTYPE_T; - resultspec.dsc$b_class = DSC$K_CLASS_D; - resultspec.dsc$a_pointer = NULL; - filespec.dsc$w_length = strlen(item); - /* - * Only return version specs, if the caller specified a version - */ - had_version = strchr(item, ';'); - while (1 == (1&lib$find_file(&filespec, &resultspec, &context, - &defaultspec, 0, &status_value, &0))) - { - char *string; - char *c; - - if (NULL == (string = calloc(1, resultspec.dsc$w_length+1))) - { - errno = ENOMEM; - perror(""); - exit(EXIT_ERR); - } - strncpy(string, resultspec.dsc$a_pointer, resultspec.dsc$w_length); - string[resultspec.dsc$w_length] = '\0'; - if (NULL == had_version) - *((char *)strrchr(string, ';')) = '\0'; - /* - * Be consistent with what the C RTL has already done to the rest of - * the argv items and lowercase all of these names. - */ - for (c = string; *c; ++c) - if (isupper(*c)) - *c = tolower(*c); - add_item(head, tail, string, count); - ++expcount; - } - if (expcount == 0) - add_item(head, tail, item, count); - lib$sfree1_dd(&resultspec); - lib$find_file_end(&context); -} - -static int child_st[2]; /* Event Flag set when child process completes */ - -static short child_chan;/* I/O Channel for Pipe Mailbox */ - -static exit_handler(status) -int *status; -{ -short iosb[4]; - - if (0 == child_st[0]) - { -#ifdef DEBUG - fprintf(stderr, "Waiting for Child Process to Finnish . . .\n"); -#endif - fflush(stdout); /* Have to flush pipe for binary data to */ - /* terminate properly -- */ -#ifdef DEBUG - fprintf(stderr, " stdout flushed. . .\n"); -#endif - sys$qio(0, child_chan, IO$_WRITEOF, iosb, 0, 0, 0, 0, 0, 0, 0, 0); -#ifdef DEBUG - fprintf(stderr, " Pipe terminated. . .\n"); -#endif - fclose(stdout); -#ifdef DEBUG - fprintf(stderr, " stdout closed. . .\n"); -#endif - sys$synch(0, child_st); - sys$dassgn(child_chan); - } -#ifdef DEBUG - fprintf(stderr, " sync done. . .\n"); -#endif -} - -#include /* System Information Definitions */ - -static sig_child(chan) -int chan; -{ -#ifdef DEBUG - fprintf(stderr, "Child Completion AST, st: %x\n", child_st[0] ); -#endif - if (child_st[0] == 0) - { child_st[0] = 1; } - sys$setef ( 0 ); -} - -static struct exit_control_block - { - struct exit_control_block *flink; - int (*exit_routine)(); - int arg_count; - int *status_address; - int exit_status; - } exit_block = - { - 0, - exit_handler, - 1, - &exit_block.exit_status, - 0 - }; - -static char *pipe_and_fork(cmd) -char *cmd; -{ - $DESCRIPTOR(cmddsc, cmd); - static char mbxname[64], ef = 0; - $DESCRIPTOR(mbxdsc, mbxname); - short iosb[4]; - int status; - int pid; - struct - { - short dna_buflen; - short dna_itmcod; - char *dna_buffer; - short *dna_retlen; - int listend; - } itmlst = - { - sizeof(mbxname), - DVI$_DEVNAM, - mbxname, - &mbxdsc.dsc$w_length, - 0 - }; - int mbxsize; - struct - { - short mbf_buflen; - short mbf_itmcod; - int *mbf_maxbuf; - short *mbf_retlen; - int listend; - } syiitmlst = - { - sizeof(mbxsize), - SYI$_MAXBUF, - &mbxsize, - 0, - 0 - }; - - cmddsc.dsc$w_length = strlen(cmd); - /* - * Get the SYSGEN parameter MAXBUF, and the smaller of it and 2048 as - * the size of the 'pipe' mailbox. - */ - if (1 == (1&(vaxc$errno = sys$getsyiw(0, 0, 0, &syiitmlst, iosb, 0, 0, 0)))) - vaxc$errno = iosb[0]; - if (0 == (1&vaxc$errno)) - { - errno = EVMSERR; - perror("Can't get SYSGEN parameter value for MAXBUF"); - exit(EXIT_ERR); - } - if (mbxsize > 2048) - mbxsize = 2048; - if (0 == (1&(vaxc$errno = sys$crembx(0, &child_chan, mbxsize, mbxsize, 0, 0, 0)))) - { - errno = EVMSERR; - perror("Can't create pipe mailbox"); - exit(EXIT_ERR); - } - if (1 == (1&(vaxc$errno = sys$getdviw(0, child_chan, 0, &itmlst, iosb, - 0, 0, 0)))) - vaxc$errno = iosb[0]; - if (0 == (1&vaxc$errno)) - { - errno = EVMSERR; - perror("Can't get pipe mailbox device name"); - exit(EXIT_ERR); - } - mbxname[mbxdsc.dsc$w_length] = '\0'; -#ifdef DEBUG - fprintf(stderr, "Pipe Mailbox Name = '%s'\n", mbxname); -#endif - if (0 == (1&(vaxc$errno = lib$spawn(&cmddsc, &mbxdsc, 0, &1, - 0, &pid, child_st, &ef, sig_child, - &child_chan)))) - { - errno = EVMSERR; - perror("Can't spawn subprocess"); - exit(EXIT_ERR); - } -#ifdef DEBUG - fprintf(stderr, "Subprocess's Pid = %08X\n", pid); -#endif - sys$dclexh(&exit_block); - return(mbxname); -} - -background_process(argc, argv) -int argc; -char **argv; -{ -char command[2048] = "$"; -$DESCRIPTOR(value, command); -$DESCRIPTOR(cmd, "BACKGROUND$COMMAND"); -$DESCRIPTOR(null, "NLA0:"); -int pid; - - strcat(command, argv[0]); - while (--argc) - { - strcat(command, " \""); - strcat(command, *(++argv)); - strcat(command, "\""); - } - value.dsc$w_length = strlen(command); - if (0 == (1&(vaxc$errno = lib$set_symbol(&cmd, &value)))) - { - errno = EVMSERR; - perror("Can't create symbol for subprocess command"); - exit(EXIT_ERR); - } - if (0 == (1&(vaxc$errno = lib$spawn(&cmd, &null, 0, &17, 0, &pid)))) - { - errno = EVMSERR; - perror("Can't spawn subprocess"); - exit(EXIT_ERR); - } -#ifdef DEBUG - fprintf(stderr, "%s\n", command); -#endif - fprintf(stderr, "%08X\n", pid); - return(EXIT_OK); -} - -/* got this off net.sources */ - -#ifdef VMS -#define index strchr -#endif /*VMS*/ - -/* - * get option letter from argument vector - */ -int opterr = 1, /* useless, never set or used */ - optind = 1, /* index into parent argv vector */ - optopt; /* character checked for validity */ -char *optarg; /* argument associated with option */ - -#define BADCH (int)'?' -#define EMSG "" -#define tell(s) fputs(progname,stderr);fputs(s,stderr); \ - fputc(optopt,stderr);fputc('\n',stderr);return(BADCH); - -getopt(nargc,nargv,ostr) -int nargc; -char **nargv, - *ostr; -{ - static char *place = EMSG; /* option letter processing */ - register char *oli; /* option letter list index */ - char *index(); - char *progname; - - if(!*place) { /* update scanning pointer */ - if(optind >= nargc || *(place = nargv[optind]) != '-' || !*++place) return(EOF); - if (*place == '-') { /* found "--" */ - ++optind; - return(EOF); - } - } /* option letter okay? */ - if ((optopt = (int)*place++) == (int)':' || !(oli = index(ostr,optopt))) { - if(!*place) ++optind; -#ifdef VMS - progname = strrchr(nargv[0],']'); -#else - progname = rindex(nargv[0],'/'); -#endif - if (!progname) progname = nargv[0]; else progname++; - tell(": illegal option -- "); - } - if (*++oli != ':') { /* don't need argument */ - optarg = NULL; - if (!*place) ++optind; - } - else { /* need an argument */ - if (*place) optarg = place; /* no white space */ - else if (nargc <= ++optind) { /* no arg */ - place = EMSG; -#ifdef VMS - progname = strrchr(nargv[0],']'); -#else - progname = rindex(nargv[0],'/'); -#endif - if (!progname) progname = nargv[0]; else progname++; - tell(": option requires an argument -- "); - } - else optarg = nargv[optind]; /* white space */ - place = EMSG; - ++optind; - } - return(optopt); /* dump back option letter */ -} -#endif /* VMS */ diff --git a/panda/src/pnm/libpbm2.c b/panda/src/pnm/libpbm2.c deleted file mode 100644 index b3f87baf40..0000000000 --- a/panda/src/pnm/libpbm2.c +++ /dev/null @@ -1,134 +0,0 @@ -/* libpbm2.c - pbm utility library part 2 -** -** Copyright (C) 1988 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include "pbm.h" -#include "libpbm.h" - -static bit pbm_getbit ARGS((FILE *)); -static bit -pbm_getbit( file ) - FILE* file; - { - register char ch; - - do - { - ch = pbm_getc( file ); - } - while ( ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' ); - - if ( ch != '0' && ch != '1' ) - pm_error( "junk in file where bits should be" ); - - return ( ch == '1' ) ? 1 : 0; - } - -int -pbm_readmagicnumber( file ) - FILE* file; - { - int ich1, ich2; - - ich1 = getc( file ); - if ( ich1 == EOF ) - pm_error( "EOF / read error reading magic number" ); - ich2 = getc( file ); - if ( ich2 == EOF ) - pm_error( "EOF / read error reading magic number" ); - return ich1 * 256 + ich2; - } - -void -pbm_readpbminitrest( file, colsP, rowsP ) - FILE* file; - int* colsP; - int* rowsP; - { - /* Read size. */ - *colsP = pbm_getint( file ); - *rowsP = pbm_getint( file ); - } - -void -pbm_readpbminit( file, colsP, rowsP, formatP ) - FILE* file; - int* colsP; - int* rowsP; - int* formatP; - { - /* Check magic number. */ - *formatP = pbm_readmagicnumber( file ); - switch ( PBM_FORMAT_TYPE(*formatP) ) - { - case PBM_TYPE: - pbm_readpbminitrest( file, colsP, rowsP ); - break; - - default: - pm_error( "bad magic number - not a pbm file" ); - } - } - -void -pbm_readpbmrow( file, bitrow, cols, format ) - FILE* file; - bit* bitrow; - int cols, format; - { - register int col, bitshift; - register unsigned char item; - register bit* bP; - - switch ( format ) - { - case PBM_FORMAT: - for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) - *bP = pbm_getbit( file ); - break; - - case RPBM_FORMAT: - bitshift = -1; - for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) - { - if ( bitshift == -1 ) - { - item = pbm_getrawbyte( file ); - bitshift = 7; - } - *bP = ( item >> bitshift ) & 1; - --bitshift; - } - break; - - default: - pm_error( "can't happen" ); - } - } - -bit** -pbm_readpbm( file, colsP, rowsP ) - FILE* file; - int* colsP; - int* rowsP; - { - register bit** bits; - int format, row; - - pbm_readpbminit( file, colsP, rowsP, &format ); - - bits = pbm_allocarray( *colsP, *rowsP ); - - for ( row = 0; row < *rowsP; ++row ) - pbm_readpbmrow( file, bits[row], *colsP, format ); - - return bits; - } diff --git a/panda/src/pnm/libpbm3.c b/panda/src/pnm/libpbm3.c deleted file mode 100644 index 0c238bf2b1..0000000000 --- a/panda/src/pnm/libpbm3.c +++ /dev/null @@ -1,123 +0,0 @@ -/* libpbm3.c - pbm utility library part 3 -** -** Copyright (C) 1988 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include "pbm.h" -#include "libpbm.h" - -static void pbm_writepbmrowplain ARGS((FILE* file, bit* bitrow, int cols)); -#ifdef PBMPLUS_RAWBITS -static void pbm_writepbmrowraw ARGS((FILE* file, bit* bitrow, int cols)); -#endif /* PBMPLUS_RAWBITS */ -void -pbm_writepbminit( file, cols, rows, forceplain ) - FILE* file; - int cols, rows; - int forceplain; - { -#ifdef PBMPLUS_RAWBITS - if ( ! forceplain ) { - fprintf( file, "%c%c\n%d %d\n", PBM_MAGIC1, RPBM_MAGIC2, cols, rows ); -#ifdef VMS - set_outfile_binary(); -#endif - } - else - fprintf( file, "%c%c\n%d %d\n", PBM_MAGIC1, PBM_MAGIC2, cols, rows ); -#else /*PBMPLUS_RAWBITS*/ - fprintf( file, "%c%c\n%d %d\n", PBM_MAGIC1, PBM_MAGIC2, cols, rows ); -#endif /*PBMPLUS_RAWBITS*/ - } - -#ifdef PBMPLUS_RAWBITS -static void -pbm_writepbmrowraw( file, bitrow, cols ) - FILE* file; - bit* bitrow; - int cols; - { - register int col, bitshift; - register unsigned char item; - register bit* bP; - - bitshift = 7; - item = 0; - for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) - { - if ( *bP ) - item += 1 << bitshift; - --bitshift; - if ( bitshift == -1 ) - { - (void) putc( item, file ); - bitshift = 7; - item = 0; - } - } - if ( bitshift != 7 ) - (void) putc( item, file ); - } -#endif /*PBMPLUS_RAWBITS*/ - -static void -pbm_writepbmrowplain( file, bitrow, cols ) - FILE* file; - bit* bitrow; - int cols; - { - register int col, charcount; - register bit* bP; - - charcount = 0; - for ( col = 0, bP = bitrow; col < cols; ++col, ++bP ) - { - if ( charcount >= 70 ) - { - (void) putc( '\n', file ); - charcount = 0; - } - (void) putc( *bP ? '1' : '0', file ); - ++charcount; - } - (void) putc( '\n', file ); - } - -void -pbm_writepbmrow( file, bitrow, cols, forceplain ) - FILE* file; - bit* bitrow; - int cols; - int forceplain; - { -#ifdef PBMPLUS_RAWBITS - if ( ! forceplain ) - pbm_writepbmrowraw( file, bitrow, cols ); - else - pbm_writepbmrowplain( file, bitrow, cols ); -#else /*PBMPLUS_RAWBITS*/ - pbm_writepbmrowplain( file, bitrow, cols ); -#endif /*PBMPLUS_RAWBITS*/ - } - -void -pbm_writepbm( file, bits, cols, rows, forceplain ) - FILE* file; - bit** bits; - int cols, rows; - int forceplain; - { - int row; - - pbm_writepbminit( file, cols, rows, forceplain ); - - for ( row = 0; row < rows; ++row ) - pbm_writepbmrow( file, bits[row], cols, forceplain ); - } diff --git a/panda/src/pnm/libpbm4.c b/panda/src/pnm/libpbm4.c deleted file mode 100644 index 2798a59d2a..0000000000 --- a/panda/src/pnm/libpbm4.c +++ /dev/null @@ -1,80 +0,0 @@ -/* libpbm4.c - pbm utility library part 4 -** -** Copyright (C) 1988 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include "pbm.h" -#include "libpbm.h" - -char -pbm_getc( file ) - FILE* file; - { - register int ich; - register char ch; - - ich = getc( file ); - if ( ich == EOF ) - pm_error( "EOF / read error" ); - ch = (char) ich; - - if ( ch == '#' ) - { - do - { - ich = getc( file ); - if ( ich == EOF ) - pm_error( "EOF / read error" ); - ch = (char) ich; - } - while ( ch != '\n' && ch != '\r' ); - } - - return ch; - } - -unsigned char -pbm_getrawbyte( file ) - FILE* file; - { - register int iby; - - iby = getc( file ); - if ( iby == EOF ) - pm_error( "EOF / read error" ); - return (unsigned char) iby; - } - -int -pbm_getint( file ) - FILE* file; - { - register char ch; - register int i; - - do - { - ch = pbm_getc( file ); - } - while ( ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r' ); - - if ( ch < '0' || ch > '9' ) - pm_error( "junk in file where an integer should be" ); - - i = 0; - do - { - i = i * 10 + ch - '0'; - ch = pbm_getc( file ); - } - while ( ch >= '0' && ch <= '9' ); - - return i; - } diff --git a/panda/src/pnm/libpbm5.c b/panda/src/pnm/libpbm5.c deleted file mode 100644 index 4e0c720c65..0000000000 --- a/panda/src/pnm/libpbm5.c +++ /dev/null @@ -1,1090 +0,0 @@ -/* libpbm5.c - pbm utility library part 5 -** -** Font routines. -** -** Support for BDF fonts Copyright 1993 by George Phillips. -** -** Copyright (C) 1991 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include "pbm.h" -#include "pbmfont.h" - -#ifndef min -#define min(a,b) ((a) < (b) ? (a) : (b)) -#endif - -/* The default font, packed in hex so this source file doesn't get huge. -** You can replace this with your own font using pbm_dumpfont(). -*/ -#define DEFAULTFONT_ROWS 155 -#define DEFAULTFONT_COLS 112 -static unsigned long defaultfont_bits[DEFAULTFONT_ROWS][(DEFAULTFONT_COLS+31)/32] = { - {0x00000000L,0x20000c00L,0x10000000L,0x00000000L}, - {0xc600a000L,0x42000810L,0x00000002L,0x00000063L}, - {0x6c00a000L,0x45000810L,0x00000002L,0x00000036L}, - {0x6c00a000L,0x88800808L,0xf2e1dee2L,0x00000036L}, - {0x54000000L,0x80000800L,0x11122442L,0x0000002aL}, - {0x54000001L,0x00000800L,0x11122442L,0x0000002aL}, - {0x54000001L,0x00000800L,0x11122282L,0x0000002aL}, - {0x44000102L,0x00000800L,0x11122382L,0x00000022L}, - {0xee000102L,0x00000800L,0x11e1e102L,0x00000077L}, - {0x00000204L,0x00000800L,0x11002102L,0x00000000L}, - {0x00000000L,0x00000c00L,0x11002102L,0x00000000L}, - {0x00000000L,0x003f8000L,0xe3807600L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x02000080L,0x00040000L,0x00120000L,0x00000001L}, - {0x04000082L,0x828e1838L,0x20210100L,0x00000002L}, - {0x04000082L,0x82912448L,0x20210100L,0x00000002L}, - {0x08000082L,0x8fd01940L,0x404087c2L,0x00000004L}, - {0x08000080L,0x050c0622L,0x00408102L,0x00000004L}, - {0x10000080L,0x05061874L,0x0040828fL,0x00008008L}, - {0x10000080L,0x1f912688L,0x00408002L,0x00000008L}, - {0x20000000L,0x0a11098cL,0x00408002L,0x00000010L}, - {0x20000080L,0x0a0e0672L,0x00210000L,0x00000010L}, - {0x40000000L,0x00040000L,0x00210000L,0x00000020L}, - {0x00000000L,0x00000000L,0x00120000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x004e0838L,0x7023e1cfL,0x00008000L}, - {0x00000000L,0x00913844L,0x88620208L,0x00008000L}, - {0x08000000L,0x00910844L,0x08a20401L,0x00000004L}, - {0x10000000L,0x01110844L,0x08a20401L,0x00000008L}, - {0x20000000L,0x01110808L,0x3123c781L,0x00000010L}, - {0x400003e0L,0x02110810L,0x0a202441L,0x00000020L}, - {0x20000000L,0x02110820L,0x0bf02442L,0x00000010L}, - {0x10008000L,0x04110844L,0x88242442L,0x00000008L}, - {0x08008002L,0x040e3e7cL,0x7073c382L,0x00000004L}, - {0x00010000L,0x08000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x0000e1c0L,0x00000000L,0x00000000L,0x00000000L}, - {0x00011220L,0x00000000L,0x70e38f87L,0x00000000L}, - {0x20011220L,0x00020020L,0x89108448L,0x00008010L}, - {0x10011220L,0x00040010L,0x09314448L,0x00008008L}, - {0x0800e221L,0x02083e08L,0x11514788L,0x00000004L}, - {0x040111e0L,0x00100004L,0x2153e448L,0x00000002L}, - {0x08011020L,0x00083e08L,0x213a2448L,0x00008004L}, - {0x10011040L,0x02040010L,0x01022448L,0x00008008L}, - {0x2000e381L,0x02020020L,0x20e77f87L,0x00000010L}, - {0x00000000L,0x04000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x3803e7efL,0xc73bbe3dL,0xdb863ce7L,0x0000001cL}, - {0x44011224L,0x48910808L,0x91036648L,0x00008022L}, - {0x4c011285L,0x48910808L,0xa1036648L,0x00008026L}, - {0x54011387L,0x081f0808L,0xc102a548L,0x0000802aL}, - {0x54011285L,0x09910808L,0xe102a548L,0x0000802aL}, - {0x4e011204L,0x08910848L,0x9112a4c8L,0x00008027L}, - {0x40011224L,0x08910848L,0x891224c8L,0x00008020L}, - {0x3803e7efL,0x073bbe31L,0xcff77e47L,0x0000001cL}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000003L,0x00000000L}, - {0x0003e1cfL,0x87bff7efL,0xdfbf77c2L,0x00000000L}, - {0x00013224L,0x48a4a244L,0x89122442L,0x00000000L}, - {0x00011224L,0x4824a244L,0xa8a14482L,0x00000000L}, - {0x00013227L,0x8e04226cL,0xa8414102L,0x00000000L}, - {0x0001e224L,0x83842228L,0xa8a08102L,0x00000000L}, - {0x00010224L,0x40842228L,0xd8a08242L,0x00000000L}, - {0x00010224L,0x48843638L,0x51108442L,0x00000000L}, - {0x0003c1ceL,0x6f1f1c10L,0x53b9c7c2L,0x00000000L}, - {0x00000060L,0x00000000L,0x00000002L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000003L,0x00000000L}, - {0xfe000000L,0x00000000L,0x00000000L,0x0000007fL}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00010180L,0x000000c0L,0x003001c0L,0x00000000L}, - {0x08008081L,0x00040040L,0x00100200L,0x00000004L}, - {0x10008082L,0x80040040L,0x00100200L,0x00000008L}, - {0x10004084L,0x40023c78L,0x70f1c7c7L,0x00004008L}, - {0x10004080L,0x00000244L,0x89122208L,0x00008008L}, - {0x20002080L,0x00001e44L,0x8113e208L,0x00008010L}, - {0x10002080L,0x00002244L,0x81120208L,0x00008008L}, - {0x10001080L,0x00002244L,0x89122208L,0x00008008L}, - {0x10001080L,0x00001db8L,0x70e9c787L,0x00008008L}, - {0x10000880L,0x00000000L,0x00000000L,0x00008008L}, - {0x08000180L,0x00000000L,0x00000000L,0x00008004L}, - {0x00000000L,0x1fc00000L,0x00000007L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00030080L,0x981c0000L,0x00000000L,0x00000000L}, - {0x20010000L,0x08040000L,0x00000000L,0x00000010L}, - {0x10010000L,0x08040000L,0x00000000L,0x00000008L}, - {0x10016387L,0x898474b8L,0x72e1d5c7L,0x00000008L}, - {0x10019080L,0x8a042a64L,0x89122208L,0x00008008L}, - {0x08011080L,0x8c042a44L,0x89122207L,0x00000004L}, - {0x10011080L,0x8a042a44L,0x89122200L,0x00008008L}, - {0x10011080L,0x89042a44L,0x89122208L,0x00008008L}, - {0x1003bbe0L,0x98dfebe6L,0x71e1e787L,0x00000008L}, - {0x10000000L,0x80000000L,0x01002000L,0x00000008L}, - {0x20000000L,0x80000000L,0x01002000L,0x00000010L}, - {0x00000007L,0x00000000L,0x03807000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00008000L,0x00000000L,0x10410000L,0x00000000L}, - {0x00008000L,0x00000000L,0x20408000L,0x00000000L}, - {0x0001f66eL,0xfdfbf77cL,0x20408000L,0x00000000L}, - {0x24008224L,0x488a2248L,0x20408240L,0x00000012L}, - {0x54008224L,0x4a842210L,0x40404540L,0x0000002aL}, - {0x48008222L,0x8a8a1420L,0x20408480L,0x00000024L}, - {0x00008a23L,0x85111c44L,0x20408000L,0x00000000L}, - {0x000071d1L,0x0531887cL,0x20408000L,0x00000000L}, - {0x00000000L,0x00000800L,0x20408000L,0x00000000L}, - {0x00000000L,0x00000800L,0x10410000L,0x00000000L}, - {0x00000000L,0x00003000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x00000000L,0x00000000L,0x00000000L}, - {0x00000000L,0x20000c00L,0x10000000L,0x00000000L}, - {0xc600a000L,0x42000810L,0x00000002L,0x00000063L}, - {0x6c00a000L,0x45000810L,0x00000002L,0x00000036L}, - {0x6c00a000L,0x88800808L,0xf2e1dee2L,0x00000036L}, - {0x54000000L,0x80000800L,0x11122442L,0x0000002aL}, - {0x54000001L,0x00000800L,0x11122442L,0x0000002aL}, - {0x54000001L,0x00000800L,0x11122282L,0x0000002aL}, - {0x44000102L,0x00000800L,0x11122382L,0x00000022L}, - {0xee000102L,0x00000800L,0x11e1e102L,0x00000077L}, - {0x00000204L,0x00000800L,0x11002102L,0x00000000L}, - {0x00000000L,0x00000c00L,0x11002102L,0x00000000L}, - {0x00000000L,0x003f8000L,0xe3807600L,0x00000000L} - }; - -/* A default BDF font */ -/* Not as nicely compacted as the PBM font, oh well. */ - -static struct glyph _g[190] = { - { 1, 1, 0, 0, 3, "\0" }, - { 1, 9, 1, 0, 3, "\1\1\1\1\1\1\1\0\1" }, - { 3, 3, 1, 6, 5, "\1\0\1\1\0\1\1\0\1" }, - { 5, 8, 0, 0, 6, "\0\1\0\1\0\0\1\0\1\0\1\1\1\1\1\0\1\0\1\0\0\1\0\1\0\1\1\1\1\1\0\1\0\1\0\0\1\0\1\0" }, - { 5, 11, 0, -1, 6, "\0\0\1\0\0\0\1\1\1\0\1\0\1\0\1\1\0\1\0\0\0\1\1\0\0\0\0\1\1\0\0\0\1\0\1\0\0\1\0\1\1\0\1\0\1\0\1\1\1\0\0\0\1\0\0" }, - { 8, 9, 0, 0, 9, "\0\1\1\0\0\0\1\1\1\0\0\1\1\1\1\0\1\0\0\1\0\1\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" }, - { 6, 12, 0, -3, 6, "\0\0\0\0\1\0\0\0\0\1\0\0\0\0\0\0\0\0\1\1\0\0\1\1\0\1\0\0\1\0\0\1\0\1\1\0\0\1\0\1\0\0\0\0\1\1\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\1\0\0\0\0\1\1\0\0\0\0" }, - { 5, 12, 0, -3, 6, "\1\1\0\0\0\0\1\0\0\0\0\1\0\0\0\0\1\1\1\0\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\0\0\1\0\1\1\1\0\0\1\0\0\0\0\1\0\0\0\1\1\1\0\0" }, - { 6, 11, 0, -3, 6, "\0\1\0\0\1\0\0\0\0\0\0\0\1\1\0\0\1\1\0\1\0\0\1\0\0\1\0\1\1\0\0\1\0\1\0\0\0\0\1\1\0\0\0\0\1\0\0\0\0\0\1\0\0\0\0\1\0\0\0\0\1\1\0\0\0\0" } -}; - -static struct font default_bdffont = { 14, 15, -1, -3, { - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - _g + 0, - _g + 1, - _g + 2, - _g + 3, - _g + 4, - _g + 5, - _g + 6, - _g + 7, - _g + 8, - _g + 9, - _g + 10, - _g + 11, - _g + 12, - _g + 13, - _g + 14, - _g + 15, - _g + 16, - _g + 17, - _g + 18, - _g + 19, - _g + 20, - _g + 21, - _g + 22, - _g + 23, - _g + 24, - _g + 25, - _g + 26, - _g + 27, - _g + 28, - _g + 29, - _g + 30, - _g + 31, - _g + 32, - _g + 33, - _g + 34, - _g + 35, - _g + 36, - _g + 37, - _g + 38, - _g + 39, - _g + 40, - _g + 41, - _g + 42, - _g + 43, - _g + 44, - _g + 45, - _g + 46, - _g + 47, - _g + 48, - _g + 49, - _g + 50, - _g + 51, - _g + 52, - _g + 53, - _g + 54, - _g + 55, - _g + 56, - _g + 57, - _g + 58, - _g + 59, - _g + 60, - _g + 61, - _g + 62, - _g + 63, - _g + 64, - _g + 65, - _g + 66, - _g + 67, - _g + 68, - _g + 69, - _g + 70, - _g + 71, - _g + 72, - _g + 73, - _g + 74, - _g + 75, - _g + 76, - _g + 77, - _g + 78, - _g + 79, - _g + 80, - _g + 81, - _g + 82, - _g + 83, - _g + 84, - _g + 85, - _g + 86, - _g + 87, - _g + 88, - _g + 89, - _g + 90, - _g + 91, - _g + 92, - _g + 93, - _g + 94, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - _g + 95, - _g + 96, - _g + 97, - _g + 98, - _g + 99, - _g + 100, - _g + 101, - _g + 102, - _g + 103, - _g + 104, - _g + 105, - _g + 106, - _g + 107, - _g + 108, - _g + 109, - _g + 110, - _g + 111, - _g + 112, - _g + 113, - _g + 114, - _g + 115, - _g + 116, - _g + 117, - _g + 118, - _g + 119, - _g + 120, - _g + 121, - _g + 122, - _g + 123, - _g + 124, - _g + 125, - _g + 126, - _g + 127, - _g + 128, - _g + 129, - _g + 130, - _g + 131, - _g + 132, - _g + 133, - _g + 134, - _g + 135, - _g + 136, - _g + 137, - _g + 138, - _g + 139, - _g + 140, - _g + 141, - _g + 142, - _g + 143, - _g + 144, - _g + 145, - _g + 146, - _g + 147, - _g + 148, - _g + 149, - _g + 150, - _g + 151, - _g + 152, - _g + 153, - _g + 154, - _g + 155, - _g + 156, - _g + 157, - _g + 158, - _g + 159, - _g + 160, - _g + 161, - _g + 162, - _g + 163, - _g + 164, - _g + 165, - _g + 166, - _g + 167, - _g + 168, - _g + 169, - _g + 170, - _g + 171, - _g + 172, - _g + 173, - _g + 174, - _g + 175, - _g + 176, - _g + 177, - _g + 178, - _g + 179, - _g + 180, - _g + 181, - _g + 182, - _g + 183, - _g + 184, - _g + 185, - _g + 186, - _g + 187, - _g + 188, - _g + 189 - } -}; - -struct font* -pbm_defaultfont( name ) - char* name; - { - bit** defaultfont; - int row, col, scol; - unsigned long l; - - if (!strcmp(name, "bdf")) - return &default_bdffont; - - if (strcmp(name, "fixed")) - pm_error( "built-in font name unknown, try 'bdf' or 'fixed'" ); - - defaultfont = pbm_allocarray( DEFAULTFONT_COLS, DEFAULTFONT_ROWS ); - for ( row = 0; row < DEFAULTFONT_ROWS; ++row ) - { - for ( col = 0; col < DEFAULTFONT_COLS; col += 32 ) - { - l = defaultfont_bits[row][col / 32]; - for ( scol = min( col + 32, DEFAULTFONT_COLS ) - 1; - scol >= col; --scol ) - { - if ( l & 1 ) - defaultfont[row][scol] = 1; - else - defaultfont[row][scol] = 0; - l >>= 1; - } - } - } - - return pbm_dissectfont( defaultfont, DEFAULTFONT_ROWS, DEFAULTFONT_COLS ); - } - -struct font* -pbm_dissectfont( font, frows, fcols ) - bit** font; - int frows; - int fcols; - { - /* - ** This routine expects a font bitmap representing the following text: - ** - ** (0,0) - ** M ",/^_[`jpqy| M - ** - ** / !"#$%&'()*+ / - ** < ,-./01234567 < - ** > 89:;<=>?@ABC > - ** @ DEFGHIJKLMNO @ - ** _ PQRSTUVWXYZ[ _ - ** { \]^_`abcdefg { - ** } hijklmnopqrs } - ** ~ tuvwxyz{|}~ ~ - ** - ** M ",/^_[`jpqy| M - ** - ** The bitmap must be cropped exactly to the edges. - ** - ** The dissection works by finding the first blank row and column; that - ** gives the height and width of the maximum-sized character, which is - ** not too useful. But the distance from there to the opposite side is - ** an integral multiple of the cell size, and that's what we need. Then - ** it's just a matter of filling in all the coordinates. - ** - ** The difference between char_height, char_width and char_aheight, - ** char_awidth is that the first is the size of the cell including - ** spacing, while the second is just the actual maximum-size character. - */ - int char_width, char_height, char_awidth, char_aheight; - int brow, bcol, row, col, d, ch, r, c, i; - struct font* fn; - struct glyph* glyph; - char* bmap; - bit b; - - /* Find first blank row. */ - for ( brow = 0; brow < frows / 6; ++brow ) - { - b = font[brow][0]; - for ( col = 1; col < fcols; ++col ) - if ( font[brow][col] != b ) - goto nextrow; - goto gotblankrow; - nextrow: ; - } - pm_error( "couldn't find blank row in font" ); - -gotblankrow: - /* Find first blank col. */ - for ( bcol = 0; bcol < fcols / 8; ++bcol ) - { - b = font[0][bcol]; - for ( row = 1; row < frows; ++row ) - if ( font[row][bcol] != b ) - goto nextcol; - goto gotblankcol; - nextcol: ; - } - pm_error( "couldn't find blank col in font" ); - -gotblankcol: - /* Now compute character cell size. */ - d = frows - brow; - char_height = d / 11; - if ( char_height * 11 != d ) - pm_error( "problem computing character cell height" ); - d = fcols - bcol; - char_width = d / 15; - if ( char_width * 15 != d ) - pm_error( "problem computing character cell width" ); - char_aheight = brow; - char_awidth = bcol; - - /* Now convert to a general font */ - - fn = (struct font*) malloc( sizeof(struct font) ); - if ( fn == (struct font*) 0 ) - pm_error( "out of memory allocating font structure" ); - - fn->maxwidth = char_awidth; - fn->maxheight = char_height; - fn->x = fn->y = 0; - for (i = 0; i < 256; i++) - fn->glyph[i] = 0; - fn->oldfont = font; - fn->frows = frows; - fn->fcols = fcols; - - glyph = (struct glyph*) malloc( sizeof(struct glyph) * 95 ); - if ( glyph == (struct glyph*) 0 ) - pm_error( "out of memory allocating glyphs" ); - - bmap = (char*) malloc( fn->maxwidth * fn->maxheight * 95 ); - if ( bmap == (char*) 0) - pm_error( "out of memory allocating glyph data" ); - - /* Now fill in the 0,0 coords. */ - row = char_height * 2; - col = char_width * 2; - for ( ch = 0; ch < 95; ++ch ) - { - glyph[ch].width = fn->maxwidth; - glyph[ch].height = fn->maxheight; - glyph[ch].x = glyph[ch].y = 0; - glyph[ch].xadd = char_width; - - for ( r = 0; r < glyph[ch].height; ++r ) - for ( c = 0; c < glyph[ch].width; ++c ) - bmap[r * glyph[ch].width + c] = font[row + r][col + c]; - - glyph[ch].bmap = bmap; - bmap += glyph[ch].width * glyph[ch].height; - - fn->glyph[ch + 32] = glyph + ch; - - col += char_width; - if ( col >= char_width * 14 ) - { - col = char_width * 2; - row += char_height; - } - } - - return fn; - } - -struct font* -pbm_loadfont( filename ) -char* filename; -{ - FILE* fp; - struct font* fn; - char line[256]; - - fp = pm_openr( filename ); - fgets(line, 256, fp); - pm_close( fp ); - - if (line[0] == PBM_MAGIC1 && - (line[1] == PBM_MAGIC2 || line[1] == RPBM_MAGIC2)) - { - return pbm_loadpbmfont( filename ); - } - else if (!strncmp(line, "STARTFONT", 9)) { - if (!(fn = pbm_loadbdffont( filename ))) - pm_error( "could not load BDF font file" ); - return fn; - } - else - pm_error( "font file not in a recognized format "); - return NULL; /* to make compiler happy; can't get here. */ -} - -struct font* pbm_loadpbmfont( filename ) -char* filename; -{ - FILE* ifp; - bit** font; - int fcols, frows; - - ifp = pm_openr( filename ); - font = pbm_readpbm( ifp, &fcols, &frows ); - pm_close( ifp ); - return pbm_dissectfont( font, frows, fcols ); -} - -void -pbm_dumpfont( fn ) - struct font* fn; -{ - /* Dump out font as C source code. */ - int row, col, scol, lperrow; - unsigned long l; - - if (fn->oldfont) { - printf( "#define DEFAULTFONT_ROWS %d\n", fn->frows ); - printf( "#define DEFAULTFONT_COLS %d\n", fn->fcols ); - printf( "static unsigned long defaultfont_bits[DEFAULTFONT_ROWS][(DEFAULTFONT_COLS+31)/32] = {\n" ); - for ( row = 0; row < fn->frows; ++row ) - { - lperrow = 0; - for ( col = 0; col < fn->fcols; col += 32 ) - { - if ( lperrow == 0 ) - printf( " {" ); - else if ( lperrow % 6 == 0 ) - { - printf( ",\n " ); - lperrow = 0; - } - else - printf( "," ); - l = 0; - for ( scol = col; scol < min( col + 32, fn->fcols ); ++scol ) - { - l <<= 1; - if ( fn->oldfont[row][scol] ) - l |= 1; - } - printf( "0x%08lxL", l ); - ++lperrow; - } - printf( "}%s\n", row == fn->frows - 1 ? "" : "," ); - } - printf( " };\n" ); - } - else { - struct glyph* glyph; - int i, j, ng; - - ng = 0; - for (i = 0; i < 256; i++) - if (fn->glyph[i]) - ng++; - - printf("static struct glyph _g[%d] = {\n", ng); - for (i = 0; i < 256; i++) { - if (!(glyph = fn->glyph[i])) - continue; - - printf(" { %d, %d, %d, %d, %d, \"", glyph->width, glyph->height, - glyph->x, glyph->y, glyph->xadd); - - for (j = 0; j < glyph->width * glyph->height; j++) - if (glyph->bmap[j]) - printf("\\1"); - else - printf("\\0"); - - ng--; - printf("\" }%s\n", ng ? "," : ""); - } - printf("};\n"); - - printf("static struct font default_bdffont = { %d, %d, %d, %d, {\n", - fn->maxwidth, fn->maxheight, fn->x, fn->y); - - for (i = 0; i < 256; i++) { - if (fn->glyph[i]) - printf(" _g + %d", ng++); - else - printf(" 0"); - - if (i != 255) printf(","); - printf("\n"); - } - - printf(" }\n};\n"); - exit(0); - - } - -} - - -/* Routines for loading a BDF font file */ - -static int readline ARGS((FILE* fp, char* buf, char* arg[])); - -#define expect(str) if (readline(fp, line, arg) < 0 || strcmp(arg[0], (str))) \ - { fclose(fp); return 0; } - -struct font* pbm_loadbdffont(name) -char* name; -{ - FILE* fp; - char line[1024], *arg[32], *b, *hex; - int i, n, numchar, hdig, encoding; - struct font* font; - struct glyph* glyph; - - if (!(fp = fopen(name, "r"))) - return 0; - - expect("STARTFONT"); - - if (!(font = (struct font*)malloc(sizeof(struct font)))) - pm_error("no memory for font"); - font->oldfont = 0; - for (i = 0; i < 256; i++) - font->glyph[i] = 0; - - while (readline(fp, line, arg) >= 0) { - if (!strcmp(arg[0], "COMMENT")) - continue; - if (!strcmp(arg[0], "SIZE")) - continue; - - if (!strcmp(arg[0], "STARTPROPERTIES")) { - n = atoi(arg[1]); - for (; n > 0 && readline(fp, line, arg) >= 0; n--) - ; - } - else if (!strcmp(arg[0], "FONTBOUNDINGBOX")) { - font->maxwidth = atoi(arg[1]); - font->maxheight = atoi(arg[2]); - font->x = atoi(arg[3]); - font->y = atoi(arg[4]); - } - else if (!strcmp(arg[0], "ENDFONT")) { - fclose(fp); - return font; - } - else if (!strcmp(arg[0], "CHARS")) { - numchar = atoi(arg[1]); - while (numchar > 0) { - if (readline(fp, line, arg) < 0) { fclose(fp); return 0; } - if (!strcmp(arg[0], "COMMENT")) - continue; - if (strcmp(arg[0], "STARTCHAR")) { fclose(fp); return 0; } - if (!(glyph = (struct glyph*)malloc(sizeof(struct glyph)))) - pm_error("no memory for font glyph"); - - expect("ENCODING"); - if ((encoding = atoi(arg[1])) < 0) { - if (arg[2]) - encoding = atoi(arg[2]); - else { - while (readline(fp, line, arg) >= 0) - if (!strcmp(arg[0], "ENDCHAR")) - break; - - numchar--; - continue; - } - } - expect("SWIDTH"); - expect("DWIDTH"); - glyph->xadd = atoi(arg[1]); - expect("BBX"); - glyph->width = atoi(arg[1]); - glyph->height = atoi(arg[2]); - glyph->x = atoi(arg[3]); - glyph->y = atoi(arg[4]); - - if (!(glyph->bmap = (char*)malloc(glyph->width * glyph->height))) - pm_error("no memory for font glyph byte map"); - - if (readline(fp, line, arg) < 0) { fclose(fp); return 0; } - if (!strcmp(arg[0], "ATTRIBUTES")) - if (readline(fp, line, arg) < 0) { fclose(fp); return 0; } - - b = glyph->bmap; - for (n = glyph->height; n > 0; n--) { - if (readline(fp, line, arg) < 0) { fclose(fp); return 0; } - hex = line; - for (i = glyph->width; i > 0; i -= 4) { - hdig = *hex++; - if (hdig >= '0' && hdig <= '9') - hdig -= '0'; - else if (hdig >= 'a' && hdig <= 'f') - hdig -= 'a' - 10; - else if (hdig >= 'A' && hdig <= 'F') - hdig -= 'A' - 10; - - *b++ = hdig & 8 ? 1 : 0; - if (i > 1) *b++ = hdig & 4 ? 1 : 0; - if (i > 2) *b++ = hdig & 2 ? 1 : 0; - if (i > 3) *b++ = hdig & 1; - } - } - - expect("ENDCHAR"); - - font->glyph[encoding] = glyph; - - numchar--; - } - } - } - return font; -} - -static int readline(fp, buf, arg) -FILE* fp; -char* buf; -char* arg[]; -{ - if (!fgets(buf, 1024, fp)) - return -1; - - return mk_argvn(buf, arg, 32); -} - -int mk_argvn(s, vec, mk_max) -char* s; -char* vec[]; -int mk_max; -{ - int n; - - n = 0; - while (*s) { - if (isspace(*s)) { - *s++ = '\0'; - continue; - } - vec[n++] = s; - if (n >= mk_max) - break; - while (*s && !isspace(*s)) - s++; - } - vec[n] = 0; - return n; -} diff --git a/panda/src/pnm/libpgm.h b/panda/src/pnm/libpgm.h deleted file mode 100644 index 1da62bbaa8..0000000000 --- a/panda/src/pnm/libpgm.h +++ /dev/null @@ -1,11 +0,0 @@ -/* libpgm.h - internal header file for libpgm portable graymap library -*/ - -#ifndef _LIBPGM_H_ -#define _LIBPGM_H_ - -/* Here are some routines internal to the pgm library. */ - -EXPCL_PANDA void pgm_readpgminitrest( FILE* file, int* colsP, int* rowsP, gray* maxvalP ); - -#endif /*_LIBPGM_H_*/ diff --git a/panda/src/pnm/libpgm1.c b/panda/src/pnm/libpgm1.c deleted file mode 100644 index dd709144db..0000000000 --- a/panda/src/pnm/libpgm1.c +++ /dev/null @@ -1,149 +0,0 @@ -/* libpgm1.c - pgm utility library part 1 -** -** Copyright (C) 1989 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include "pgm.h" -#include "libpgm.h" -#include "pbm.h" -#include "libpbm.h" - -void -pgm_init( argcP, argv ) - int* argcP; - char* argv[]; - { - pbm_init( argcP, argv ); - } - -void -pgm_readpgminitrest( file, colsP, rowsP, maxvalP ) - FILE* file; - int* colsP; - int* rowsP; - gray* maxvalP; - { - int maxval; - - /* Read size. */ - *colsP = pbm_getint( file ); - *rowsP = pbm_getint( file ); - - /* Read maxval. */ - maxval = pbm_getint( file ); - if ( maxval > PGM_MAXMAXVAL ) - pm_error( "maxval is too large - try reconfiguring with PGM_BIGGRAYS" ); - *maxvalP = maxval; - } - -gray pgm_pbmmaxval = 1; - -void -pgm_readpgminit( file, colsP, rowsP, maxvalP, formatP ) - FILE* file; - int* colsP; - int* rowsP; - int* formatP; - gray* maxvalP; - { - /* Check magic number. */ - *formatP = pbm_readmagicnumber( file ); - switch ( PGM_FORMAT_TYPE(*formatP) ) - { - case PGM_TYPE: - pgm_readpgminitrest( file, colsP, rowsP, maxvalP ); - break; - - case PBM_TYPE: - pbm_readpbminitrest( file, colsP, rowsP ); - *maxvalP = pgm_pbmmaxval; - break; - - default: - pm_error( "bad magic number - not a pgm or pbm file" ); - } - } - -#if __STDC__ -void -pgm_readpgmrow( FILE* file, gray* grayrow, int cols, gray maxval, int format ) -#else /*__STDC__*/ -void -pgm_readpgmrow( file, grayrow, cols, maxval, format ) - FILE* file; - gray* grayrow; - int cols; - gray maxval; - int format; -#endif /*__STDC__*/ - { - register int col; - register gray* gP; - bit* bitrow; - register bit* bP; - - switch ( format ) - { - case PGM_FORMAT: - for ( col = 0, gP = grayrow; col < cols; ++col, ++gP ) - { - *gP = pbm_getint( file ); -#ifdef DEBUG - if ( *gP > maxval ) - pm_error( "value out of bounds (%u > %u)", *gP, maxval ); -#endif /*DEBUG*/ - } - break; - - case RPGM_FORMAT: - for ( col = 0, gP = grayrow; col < cols; ++col, ++gP ) - { - *gP = pbm_getrawbyte( file ); -#ifdef DEBUG - if ( *gP > maxval ) - pm_error( "value out of bounds (%u > %u)", *gP, maxval ); -#endif /*DEBUG*/ - } - break; - - case PBM_FORMAT: - case RPBM_FORMAT: - bitrow = pbm_allocrow( cols ); - pbm_readpbmrow( file, bitrow, cols, format ); - for ( col = 0, gP = grayrow, bP = bitrow; col < cols; ++col, ++gP, ++bP ) - *gP = ( *bP == PBM_WHITE ) ? maxval : 0; - pbm_freerow( bitrow ); - break; - - default: - pm_error( "can't happen" ); - } - } - -gray** -pgm_readpgm( file, colsP, rowsP, maxvalP ) - FILE* file; - int* colsP; - int* rowsP; - gray* maxvalP; - { - gray** grays; - int row; - int format; - - pgm_readpgminit( file, colsP, rowsP, maxvalP, &format ); - - grays = pgm_allocarray( *colsP, *rowsP ); - - for ( row = 0; row < *rowsP; ++row ) - pgm_readpgmrow( file, grays[row], *colsP, *maxvalP, format ); - - return grays; - } diff --git a/panda/src/pnm/libpgm2.c b/panda/src/pnm/libpgm2.c deleted file mode 100644 index cbc8bb6ddb..0000000000 --- a/panda/src/pnm/libpgm2.c +++ /dev/null @@ -1,154 +0,0 @@ -/* libpgm2.c - pgm utility library part 2 -** -** Copyright (C) 1989 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include "pgm.h" -#include "libpgm.h" - -static void putus1 ARGS((unsigned short n, FILE* file)); -static void pgm_writepgmrowplain ARGS((FILE* file, gray* grayrow, int cols, gray maxval)); -#ifdef PBMPLUS_RAWBITS -static void pgm_writepgmrowraw ARGS((FILE* file, gray* grayrow, int cols, gray maxval)); -#endif /* PBMPLUS_RAWBITS */ -#if __STDC__ -void -pgm_writepgminit( FILE* file, int cols, int rows, gray maxval, int forceplain ) -#else /*__STDC__*/ -void -pgm_writepgminit( file, cols, rows, maxval, forceplain ) - FILE* file; - int cols, rows; - gray maxval; - int forceplain; -#endif /*__STDC__*/ - { -#ifdef PBMPLUS_RAWBITS - if ( maxval <= 255 && ! forceplain ) { - fprintf( - file, "%c%c\n%d %d\n%d\n", PGM_MAGIC1, RPGM_MAGIC2, - cols, rows, maxval ); -#ifdef VMS - set_outfile_binary(); -#endif - } - else - fprintf( - file, "%c%c\n%d %d\n%d\n", PGM_MAGIC1, PGM_MAGIC2, - cols, rows, maxval ); -#else /*PBMPLUS_RAWBITS*/ - fprintf( - file, "%c%c\n%d %d\n%d\n", PGM_MAGIC1, PGM_MAGIC2, - cols, rows, maxval ); -#endif /*PBMPLUS_RAWBITS*/ - } - -static void -putus1( n, file ) - unsigned short n; - FILE* file; - { - if ( n >= 10 ) - putus1((unsigned short)( n / 10), file ); - (void) putc( n % 10 + '0', file ); - } - -#ifdef PBMPLUS_RAWBITS -static void -pgm_writepgmrowraw(FILE* file,gray* grayrow,int cols,gray maxval) - { - register int col; - register gray* gP; - - for ( col = 0, gP = grayrow; col < cols; ++col, ++gP ) - { -#ifdef DEBUG - if ( *gP > maxval ) - pm_error( "value out of bounds (%u > %u)", *gP, maxval ); -#endif /*DEBUG*/ - (void) putc( *gP, file ); - } - } -#endif /*PBMPLUS_RAWBITS*/ - -static void -pgm_writepgmrowplain(FILE* file,gray* grayrow,int cols,gray maxval) - { - register int col, charcount; - register gray* gP; - - charcount = 0; - for ( col = 0, gP = grayrow; col < cols; ++col, ++gP ) - { - if ( charcount >= 65 ) - { - (void) putc( '\n', file ); - charcount = 0; - } - else if ( charcount > 0 ) - { - (void) putc( ' ', file ); - ++charcount; - } -#ifdef DEBUG - if ( *gP > maxval ) - pm_error( "value out of bounds (%u > %u)", *gP, maxval ); -#endif /*DEBUG*/ -/* putus1( (unsigned long) *gP, file ); */ - putus1( (unsigned short) *gP, file ); - charcount += 3; - } - if ( charcount > 0 ) - (void) putc( '\n', file ); - } - -#if __STDC__ -void -pgm_writepgmrow( FILE* file, gray* grayrow, int cols, gray maxval, int forceplain ) -#else /*__STDC__*/ -void -pgm_writepgmrow( file, grayrow, cols, maxval, forceplain ) - FILE* file; - gray* grayrow; - int cols; - gray maxval; - int forceplain; -#endif /*__STDC__*/ - { -#ifdef PBMPLUS_RAWBITS - if ( maxval <= 255 && ! forceplain ) - pgm_writepgmrowraw( file, grayrow, cols, maxval ); - else - pgm_writepgmrowplain( file, grayrow, cols, maxval ); -#else /*PBMPLUS_RAWBITS*/ - pgm_writepgmrowplain( file, grayrow, cols, maxval ); -#endif /*PBMPLUS_RAWBITS*/ - } - -#if __STDC__ -void -pgm_writepgm( FILE* file, gray** grays, int cols, int rows, gray maxval, int forceplain ) -#else /*__STDC__*/ -void -pgm_writepgm( file, grays, cols, rows, maxval, forceplain ) - FILE* file; - gray** grays; - int cols, rows; - gray maxval; - int forceplain; -#endif /*__STDC__*/ - { - int row; - - pgm_writepgminit( file, cols, rows, maxval, forceplain ); - - for ( row = 0; row < rows; ++row ) - pgm_writepgmrow( file, grays[row], cols, maxval, forceplain ); - } diff --git a/panda/src/pnm/libpnm1.c b/panda/src/pnm/libpnm1.c deleted file mode 100644 index 382c048c3d..0000000000 --- a/panda/src/pnm/libpnm1.c +++ /dev/null @@ -1,131 +0,0 @@ -/* libpnm1.c - pnm utility library part 1 -** -** Copyright (C) 1989 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include "pnm.h" - -#include "ppm.h" -#include "libppm.h" - -#include "pgm.h" -#include "libpgm.h" - -#include "pbm.h" -#include "libpbm.h" - -void -pnm_init( argcP, argv ) - int* argcP; - char* argv[]; - { - ppm_init( argcP, argv ); - } - -EXPCL_PANDA xelval pnm_pbmmaxval = 1; - -void -pnm_readpnminit( file, colsP, rowsP, maxvalP, formatP ) - FILE* file; - int* colsP; - int* rowsP; - int* formatP; - xelval* maxvalP; - { - gray gmaxval; - - /* Check magic number. */ - *formatP = pbm_readmagicnumber( file ); - switch ( PNM_FORMAT_TYPE(*formatP) ) - { - case PPM_TYPE: - ppm_readppminitrest( file, colsP, rowsP, (pixval*) maxvalP ); - break; - - case PGM_TYPE: - pgm_readpgminitrest( file, colsP, rowsP, &gmaxval ); - *maxvalP = (xelval) gmaxval; - break; - - case PBM_TYPE: - pbm_readpbminitrest( file, colsP, rowsP ); - *maxvalP = pnm_pbmmaxval; - break; - - default: - pm_error( "bad magic number - not a ppm, pgm, or pbm file" ); - } - } - -#if defined(__STDC__) || defined(WIN32_VC) -void -EXPCL_PANDA pnm_readpnmrow( FILE* file, xel* xelrow, int cols, xelval maxval, int format ) -#else /*__STDC__*/ -void pnm_readpnmrow( file, xelrow, cols, maxval, format ) - FILE* file; - xel* xelrow; - xelval maxval; - int cols, format; -#endif /*__STDC__*/ - { - register int col; - register xel* xP; - gray* grayrow; - register gray* gP; - bit* bitrow; - register bit* bP; - - switch ( PNM_FORMAT_TYPE(format) ) - { - case PPM_TYPE: - ppm_readppmrow( file, (pixel*) xelrow, cols, (pixval) maxval, format ); - break; - - case PGM_TYPE: - grayrow = pgm_allocrow( cols ); - pgm_readpgmrow( file, grayrow, cols, (gray) maxval, format ); - for ( col = 0, xP = xelrow, gP = grayrow; col < cols; ++col, ++xP, ++gP ) - PNM_ASSIGN1( *xP, *gP ); - pgm_freerow( grayrow ); - break; - - case PBM_TYPE: - bitrow = pbm_allocrow( cols ); - pbm_readpbmrow( file, bitrow, cols, format ); - for ( col = 0, xP = xelrow, bP = bitrow; col < cols; ++col, ++xP, ++bP ) - PNM_ASSIGN1( *xP, *bP == PBM_BLACK ? 0: pnm_pbmmaxval ); - pbm_freerow( bitrow ); - break; - - default: - pm_error( "can't happen" ); - } - } - -xel** -pnm_readpnm( file, colsP, rowsP, maxvalP, formatP ) - FILE* file; - int* colsP; - int* rowsP; - int* formatP; - xelval* maxvalP; - { - xel** xels; - int row; - - pnm_readpnminit( file, colsP, rowsP, maxvalP, formatP ); - - xels = pnm_allocarray( *colsP, *rowsP ); - - for ( row = 0; row < *rowsP; ++row ) - pnm_readpnmrow( file, xels[row], *colsP, *maxvalP, *formatP ); - - return xels; - } diff --git a/panda/src/pnm/libpnm2.c b/panda/src/pnm/libpnm2.c deleted file mode 100644 index 3a4fc3b0a0..0000000000 --- a/panda/src/pnm/libpnm2.c +++ /dev/null @@ -1,120 +0,0 @@ -/* libpnm2.c - pnm utility library part 2 -** -** Copyright (C) 1989 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include "pnm.h" - -#include "ppm.h" -#include "libppm.h" - -#include "pgm.h" -#include "libpgm.h" - -#include "pbm.h" -#include "libpbm.h" - -#if defined(__STDC__) || defined(WIN32_VC) -void -EXPCL_PANDA pnm_writepnminit( FILE* file, int cols, int rows, xelval maxval, int format, int forceplain ) -#else /*__STDC__*/ -void -pnm_writepnminit( file, cols, rows, maxval, format, forceplain ) - FILE* file; - int cols, rows, format; - xelval maxval; - int forceplain; -#endif /*__STDC__*/ - { - switch ( PNM_FORMAT_TYPE(format) ) - { - case PPM_TYPE: - ppm_writeppminit( file, cols, rows, (pixval) maxval, forceplain ); - break; - - case PGM_TYPE: - pgm_writepgminit( file, cols, rows, (gray) maxval, forceplain ); - break; - - case PBM_TYPE: - pbm_writepbminit( file, cols, rows, forceplain ); - break; - - default: - pm_error( "can't happen" ); - } - } - -#if defined(__STDC__) || defined(WIN32_VC) -EXPCL_PANDA void pnm_writepnmrow( FILE* file, xel* xelrow, int cols, xelval maxval, int format, int forceplain ) -#else /*__STDC__*/ -void -pnm_writepnmrow( file, xelrow, cols, maxval, format, forceplain ) - FILE* file; - xel* xelrow; - int cols, format; - xelval maxval; - int forceplain; -#endif /*__STDC__*/ - { - register int col; - register xel* xP; - gray* grayrow; - register gray* gP; - bit* bitrow; - register bit* bP; - - switch ( PNM_FORMAT_TYPE(format) ) - { - case PPM_TYPE: - ppm_writeppmrow( file, (pixel*) xelrow, cols, (pixval) maxval, forceplain ); - break; - - case PGM_TYPE: - grayrow = pgm_allocrow( cols ); - for ( col = 0, gP = grayrow, xP = xelrow; col < cols; ++col, ++gP, ++xP ) - *gP = PNM_GET1( *xP ); - pgm_writepgmrow( file, grayrow, cols, (gray) maxval, forceplain ); - pgm_freerow( grayrow ); - break; - - case PBM_TYPE: - bitrow = pbm_allocrow( cols ); - for ( col = 0, bP = bitrow, xP = xelrow; col < cols; ++col, ++bP, ++xP ) - *bP = PNM_GET1( *xP ) == 0 ? PBM_BLACK : PBM_WHITE; - pbm_writepbmrow( file, bitrow, cols, forceplain ); - pbm_freerow( bitrow ); - break; - - default: - pm_error( "can't happen" ); - } - } - -#if __STDC__ -void -pnm_writepnm( FILE* file, xel** xels, int cols, int rows, xelval maxval, int format, int forceplain ) -#else /*__STDC__*/ -void -pnm_writepnm( file, xels, cols, rows, maxval, format, forceplain ) - FILE* file; - xel** xels; - xelval maxval; - int cols, rows, format; - int forceplain; -#endif /*__STDC__*/ - { - int row; - - pnm_writepnminit( file, cols, rows, maxval, format, forceplain ); - - for ( row = 0; row < rows; ++row ) - pnm_writepnmrow( file, xels[row], cols, maxval, format, forceplain ); - } diff --git a/panda/src/pnm/libpnm3.c b/panda/src/pnm/libpnm3.c deleted file mode 100644 index 6328dec9cf..0000000000 --- a/panda/src/pnm/libpnm3.c +++ /dev/null @@ -1,386 +0,0 @@ -/* libpnm3.c - pnm utility library part 3 -** -** Copyright (C) 1989, 1991 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include "pnm.h" - -#include "ppm.h" -#include "libppm.h" - -#include "pgm.h" -#include "libpgm.h" - -#include "pbm.h" -#include "libpbm.h" - -#if __STDC__ -xel -pnm_backgroundxel( xel** xels, int cols, int rows, xelval maxval, int format ) -#else /*__STDC__*/ -xel -pnm_backgroundxel( xels, cols, rows, maxval, format ) - xel** xels; - int cols, rows, format; - xelval maxval; -#endif /*__STDC__*/ - { - xel bgxel, ul, ur, ll, lr; - - /* Guess a good background value. */ - ul = xels[0][0]; - ur = xels[0][cols-1]; - ll = xels[rows-1][0]; - lr = xels[rows-1][cols-1]; - - /* First check for three corners equal. */ - if ( PNM_EQUAL( ul, ur ) && PNM_EQUAL( ur, ll ) ) - bgxel = ul; - else if ( PNM_EQUAL( ul, ur ) && PNM_EQUAL( ur, lr ) ) - bgxel = ul; - else if ( PNM_EQUAL( ul, ll ) && PNM_EQUAL( ll, lr ) ) - bgxel = ul; - else if ( PNM_EQUAL( ur, ll ) && PNM_EQUAL( ll, lr ) ) - bgxel = ur; - /* Nope, check for two corners equal. */ - else if ( PNM_EQUAL( ul, ur ) || PNM_EQUAL( ul, ll ) || - PNM_EQUAL( ul, lr ) ) - bgxel = ul; - else if ( PNM_EQUAL( ur, ll ) || PNM_EQUAL( ur, lr ) ) - bgxel = ur; - else if ( PNM_EQUAL( ll, lr ) ) - bgxel = ll; - else - { - /* Nope, we have to average the four corners. This breaks the - ** rules of pnm, but oh well. Let's try to do it portably. */ - switch ( PNM_FORMAT_TYPE(format) ) - { - case PPM_TYPE: - PPM_ASSIGN( bgxel, - PPM_GETR(ul) + PPM_GETR(ur) + PPM_GETR(ll) + PPM_GETR(lr) / 4, - PPM_GETG(ul) + PPM_GETG(ur) + PPM_GETG(ll) + PPM_GETG(lr) / 4, - PPM_GETB(ul) + PPM_GETB(ur) + PPM_GETB(ll) + PPM_GETB(lr) / 4 ); - break; - - case PGM_TYPE: - { - gray gul, gur, gll, glr; - gul = (gray) PNM_GET1( ul ); - gur = (gray) PNM_GET1( ur ); - gll = (gray) PNM_GET1( ll ); - glr = (gray) PNM_GET1( lr ); - PNM_ASSIGN1( bgxel, ( ( gul + gur + gll + glr ) / 4 ) ); - break; - } - - case PBM_TYPE: - pm_error( - "pnm_backgroundxel: four bits no two of which equal each other??" ); - - default: - pm_error( "can't happen" ); - } - } - - return bgxel; - } - -#if __STDC__ -xel -pnm_backgroundxelrow( xel* xelrow, int cols, xelval maxval, int format ) -#else /*__STDC__*/ -xel -pnm_backgroundxelrow( xelrow, cols, maxval, format ) - xel* xelrow; - int cols, format; - xelval maxval; -#endif /*__STDC__*/ - { - xel bgxel, l, r; - - /* Guess a good background value. */ - l = xelrow[0]; - r = xelrow[cols-1]; - - /* First check for both corners equal. */ - if ( PNM_EQUAL( l, r ) ) - bgxel = l; - else - { - /* Nope, we have to average the two corners. This breaks the - ** rules of pnm, but oh well. Let's try to do it portably. */ - switch ( PNM_FORMAT_TYPE(format) ) - { - case PPM_TYPE: - PPM_ASSIGN( bgxel, PPM_GETR(l) + PPM_GETR(r) / 2, - PPM_GETG(l) + PPM_GETG(r) / 2, PPM_GETB(l) + PPM_GETB(r) / 2 ); - break; - - case PGM_TYPE: - { - gray gl, gr; - gl = (gray) PNM_GET1( l ); - gr = (gray) PNM_GET1( r ); - PNM_ASSIGN1( bgxel, ( ( gl + gr ) / 2 ) ); - break; - } - - case PBM_TYPE: - { - int col, blacks; - - /* One black, one white. Gotta count. */ - for ( col = 0, blacks = 0; col < cols; ++col ) - { - if ( PNM_GET1( xelrow[col] ) == 0 ) - ++blacks; - } - if ( blacks >= cols / 2 ) - PNM_ASSIGN1( bgxel, 0 ); - else - PNM_ASSIGN1( bgxel, pnm_pbmmaxval ); - break; - } - - default: - pm_error( "can't happen" ); - } - } - - return bgxel; - } - -#if __STDC__ -xel -pnm_whitexel( xelval maxval, int format ) -#else /*__STDC__*/ -xel -pnm_whitexel( maxval, format ) - xelval maxval; - int format; -#endif /*__STDC__*/ - { - xel x; - - switch ( PNM_FORMAT_TYPE(format) ) - { - case PPM_TYPE: - PPM_ASSIGN( x, maxval, maxval, maxval ); - break; - - case PGM_TYPE: - PNM_ASSIGN1( x, maxval ); - break; - - case PBM_TYPE: - PNM_ASSIGN1( x, pnm_pbmmaxval ); - break; - - default: - pm_error( "can't happen" ); - } - - return x; - } - -#if __STDC__ -xel -pnm_blackxel( xelval maxval, int format ) -#else /*__STDC__*/ -xel -pnm_blackxel( maxval, format ) - xelval maxval; - int format; -#endif /*__STDC__*/ - { - xel x; - - switch ( PNM_FORMAT_TYPE(format) ) - { - case PPM_TYPE: - PPM_ASSIGN( x, 0, 0, 0 ); - break; - - case PGM_TYPE: - PNM_ASSIGN1( x, (xelval) 0 ); - break; - - case PBM_TYPE: - PNM_ASSIGN1( x, (xelval) 0 ); - break; - - default: - pm_error( "can't happen" ); - } - - return x; - } - -#if __STDC__ -void -pnm_invertxel( xel* xP, xelval maxval, int format ) -#else /*__STDC__*/ -void -pnm_invertxel( xP, maxval, format ) - xel* xP; - xelval maxval; - int format; -#endif /*__STDC__*/ - { - switch ( PNM_FORMAT_TYPE(format) ) - { - case PPM_TYPE: - PPM_ASSIGN( - *xP, maxval - PPM_GETR( *xP ), - maxval - PPM_GETG( *xP ), maxval - PPM_GETB( *xP ) ); - break; - - case PGM_TYPE: - PNM_ASSIGN1( *xP, (gray) maxval - (gray) PNM_GET1( *xP ) ); - break; - - case PBM_TYPE: - PNM_ASSIGN1( *xP, ( PNM_GET1( *xP ) == 0 ) ? pnm_pbmmaxval : 0 ); - break; - - default: - pm_error( "can't happen" ); - } - } - -#if __STDC__ -void -pnm_promoteformat( xel** xels, int cols, int rows, xelval maxval, int format, xelval newmaxval, int newformat ) -#else /*__STDC__*/ -void -pnm_promoteformat( xels, cols, rows, maxval, format, newmaxval, newformat ) - xel** xels; - xelval maxval, newmaxval; - int cols, rows, format, newformat; -#endif /*__STDC__*/ - { - int row; - - for ( row = 0; row < rows; ++row ) - pnm_promoteformatrow( - xels[row], cols, maxval, format, newmaxval, newformat ); - } - -#if __STDC__ -void -pnm_promoteformatrow( xel* xelrow, int cols, xelval maxval, int format, xelval newmaxval, int newformat ) -#else /*__STDC__*/ -void -pnm_promoteformatrow( xelrow, cols, maxval, format, newmaxval, newformat ) - xel* xelrow; - xelval maxval, newmaxval; - int cols, format, newformat; -#endif /*__STDC__*/ - { - register int col; - register xel* xP; - - if ( ( PNM_FORMAT_TYPE(format) == PPM_TYPE && - ( PNM_FORMAT_TYPE(newformat) == PGM_TYPE || - PNM_FORMAT_TYPE(newformat) == PBM_TYPE ) ) || - ( PNM_FORMAT_TYPE(format) == PGM_TYPE && - PNM_FORMAT_TYPE(newformat) == PBM_TYPE ) ) - pm_error( "pnm_promoteformatrow: can't promote downwards!" ); - - /* Are we promoting to the same type? */ - if ( PNM_FORMAT_TYPE(format) == PNM_FORMAT_TYPE(newformat) ) - { - if ( PNM_FORMAT_TYPE(format) == PBM_TYPE ) - return; - if ( newmaxval < maxval ) - pm_error( - "pnm_promoteformatrow: can't decrease maxval - try using pnmdepth" ); - if ( newmaxval == maxval ) - return; - /* Increase maxval. */ - switch ( PNM_FORMAT_TYPE(format) ) - { - case PGM_TYPE: - for ( col = 0, xP = xelrow; col < cols; ++col, ++xP ) - PNM_ASSIGN1( - *xP, (int) PNM_GET1(*xP) * newmaxval / maxval ); - break; - - case PPM_TYPE: - for ( col = 0, xP = xelrow; col < cols; ++col, ++xP ) - PPM_DEPTH( *xP, *xP, maxval, newmaxval ); - break; - - default: - pm_error( "shouldn't happen" ); - } - return; - } - - /* We must be promoting to a higher type. */ - switch ( PNM_FORMAT_TYPE(format) ) - { - case PBM_TYPE: - switch ( PNM_FORMAT_TYPE(newformat) ) - { - case PGM_TYPE: - for ( col = 0, xP = xelrow; col < cols; ++col, ++xP ) - if ( PNM_GET1(*xP) == 0 ) - PNM_ASSIGN1( *xP, 0 ); - else - PNM_ASSIGN1( *xP, newmaxval ); - break; - - case PPM_TYPE: - for ( col = 0, xP = xelrow; col < cols; ++col, ++xP ) - if ( PNM_GET1(*xP) == 0 ) - PPM_ASSIGN( *xP, 0, 0, 0 ); - else - PPM_ASSIGN( *xP, newmaxval, newmaxval, newmaxval ); - break; - - default: - pm_error( "can't happen" ); - } - break; - - case PGM_TYPE: - switch ( PNM_FORMAT_TYPE(newformat) ) - { - case PPM_TYPE: - if ( newmaxval < maxval ) - pm_error( - "pnm_promoteformatrow: can't decrease maxval - try using pnmdepth" ); - if ( newmaxval == maxval ) - { - for ( col = 0, xP = xelrow; col < cols; ++col, ++xP ) - PPM_ASSIGN( - *xP, PNM_GET1(*xP), PNM_GET1(*xP), PNM_GET1(*xP) ); - } - else - { /* Increase maxval. */ - for ( col = 0, xP = xelrow; col < cols; ++col, ++xP ) - PPM_ASSIGN( - *xP, (int) PNM_GET1(*xP) * newmaxval / maxval, - (int) PNM_GET1(*xP) * newmaxval / maxval, - (int) PNM_GET1(*xP) * newmaxval / maxval ); - } - break; - - default: - pm_error( "can't happen" ); - } - break; - - default: - pm_error( "can't happen" ); - } - } diff --git a/panda/src/pnm/libpnm4.c b/panda/src/pnm/libpnm4.c deleted file mode 100644 index 86b8f6e1b0..0000000000 --- a/panda/src/pnm/libpnm4.c +++ /dev/null @@ -1,453 +0,0 @@ -/* libpnm4.c - pnm utility library part 4 -** -** Copyright (C) 1988 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include "pnm.h" -#include "rast.h" - -/* -** Semi-work-alike versions of some Sun pixrect routines. Just enough -** for rasterfile reading and writing to work. -*/ - -struct pixrect* -mem_create( w, h, depth ) - int w, h, depth; - { - struct pixrect* p; - struct mpr_data* m; - - p = (struct pixrect*) malloc( sizeof(struct pixrect) ); - if ( p == NULL ) - return NULL; - p->pr_ops = NULL; - p->pr_size.x = w; - p->pr_size.y = h; - p->pr_depth = depth; - m = p->pr_data = (struct mpr_data*) malloc( sizeof(struct mpr_data) ); - if ( m == NULL ) - { - free( p ); - return NULL; - } - /* According to the documentation, linebytes is supposed to be rounded - ** up to a longword (except on 386 boxes). However, this turns out - ** not to be the case. In reality, all of Sun's code rounds up to - ** a short, not a long. - */ - m->md_linebytes = ( w * depth + 15 ) / 16 * 2; - m->md_offset.x = 0; - m->md_offset.y = 0; - m->md_flags = 0; - m->md_image = (unsigned char*) malloc( m->md_linebytes * h ); - if ( m->md_image == NULL ) - { - free( m ); - free( p ); - return NULL; - } - - return p; - } - -void -mem_free( p ) - struct pixrect* p; - { - free( p->pr_data->md_image ); - free( p->pr_data ); - free( p ); - } - -int -pr_dump( p, out, colormap, type, copy_flag ) - struct pixrect* p; - FILE* out; - colormap_t* colormap; - int type, copy_flag; - { - struct rasterfile h; - int size, besize, count; - unsigned char* beimage; - unsigned char* bp; - unsigned char c, pc; - int i, j; - - h.ras_magic = RAS_MAGIC; - h.ras_width = p->pr_size.x; - h.ras_height = p->pr_size.y; - h.ras_depth = p->pr_depth; - - h.ras_type = type; - switch ( type ) - { - case RT_OLD: - pm_error( "old rasterfile type is not supported" ); - - case RT_FORMAT_TIFF: - pm_error( "tiff rasterfile type is not supported" ); - - case RT_FORMAT_IFF: - pm_error( "iff rasterfile type is not supported" ); - - case RT_EXPERIMENTAL: - pm_error( "experimental rasterfile type is not supported" ); - - case RT_STANDARD: - case RT_FORMAT_RGB: - /* Ignore hP->ras_length. */ - h.ras_length = p->pr_size.y * p->pr_data->md_linebytes; - break; - - case RT_BYTE_ENCODED: - size = p->pr_size.y * p->pr_data->md_linebytes; - bp = p->pr_data->md_image; - beimage = (unsigned char*) malloc( size * 3 / 2 ); /* worst case */ - if ( beimage == NULL ) - return PIX_ERR; - besize = 0; - count = 0; - for ( i = 0; i < size; ++i ) - { - c = *bp++; - if ( count > 0 ) - { - if ( pc != c ) - { - if ( count == 1 && pc == 128 ) - { - beimage[besize++] = 128; - beimage[besize++] = 0; - count = 0; - } - else if ( count > 2 || pc == 128 ) - { - beimage[besize++] = 128; - beimage[besize++] = count - 1; - beimage[besize++] = pc; - count = 0; - } - else - { - for ( j = 0; j < count; ++j ) - beimage[besize++] = pc; - count = 0; - } - } - } - pc = c; - ++count; - if ( count == 256 ) - { - beimage[besize++] = 128; - beimage[besize++] = count - 1; - beimage[besize++] = c; - count = 0; - } - } - if ( count > 0 ) - { - if ( count == 1 && c == 128 ) - { - beimage[besize++] = 128; - beimage[besize++] = 0; - } - if ( count > 2 || c == 128 ) - { - beimage[besize++] = 128; - beimage[besize++] = count - 1; - beimage[besize++] = c; - } - else - { - for ( j = 0; j < count; ++j ) - beimage[besize++] = c; - } - } - h.ras_length = besize; - break; - - default: - pm_error( "unknown rasterfile type" ); - } - - if ( colormap == NULL ) - { - h.ras_maptype = RMT_NONE; - h.ras_maplength = 0; - } - else - { - h.ras_maptype = colormap->type; - switch ( colormap->type ) - { - case RMT_EQUAL_RGB: - h.ras_maplength = colormap->length * 3; - break; - - case RMT_RAW: - h.ras_maplength = colormap->length; - break; - - default: - pm_error( "unknown colormap type" ); - } - } - - if ( pm_writebiglong( out, h.ras_magic ) == -1 ) - return PIX_ERR; - if ( pm_writebiglong( out, h.ras_width ) == -1 ) - return PIX_ERR; - if ( pm_writebiglong( out, h.ras_height ) == -1 ) - return PIX_ERR; - if ( pm_writebiglong( out, h.ras_depth ) == -1 ) - return PIX_ERR; - if ( pm_writebiglong( out, h.ras_length ) == -1 ) - return PIX_ERR; - if ( pm_writebiglong( out, h.ras_type ) == -1 ) - return PIX_ERR; - if ( pm_writebiglong( out, h.ras_maptype ) == -1 ) - return PIX_ERR; - if ( pm_writebiglong( out, h.ras_maplength ) == -1 ) - return PIX_ERR; - - if ( colormap != NULL ) - { - switch ( colormap->type ) - { - case RMT_EQUAL_RGB: - if ( fwrite( colormap->map[0], 1, colormap->length, out ) != (size_t) - colormap->length ) - return PIX_ERR; - if ( fwrite( colormap->map[1], 1, colormap->length, out ) != (size_t) - colormap->length ) - return PIX_ERR; - if ( fwrite( colormap->map[2], 1, colormap->length, out ) != (size_t) - colormap->length ) - return PIX_ERR; - break; - - case RMT_RAW: - if ( fwrite( colormap->map[0], 1, colormap->length, out ) != (size_t) - colormap->length ) - return PIX_ERR; - break; - } - } - - switch ( type ) - { - case RT_STANDARD: - case RT_FORMAT_RGB: - if ( fwrite( p->pr_data->md_image, 1, h.ras_length, out ) != (size_t) - h.ras_length ) - return PIX_ERR; - break; - - case RT_BYTE_ENCODED: - if ( fwrite( beimage, 1, besize, out ) != (size_t) besize ) - { - free( beimage ); - return PIX_ERR; - } - free( beimage ); - break; - } - - return 0; - } - -int -pr_load_header( in, hP ) - FILE* in; - struct rasterfile* hP; - { - if ( pm_readbiglong( in, &(hP->ras_magic) ) == -1 ) - return PIX_ERR; - if ( hP->ras_magic != RAS_MAGIC ) - return PIX_ERR; - if ( pm_readbiglong( in, &(hP->ras_width) ) == -1 ) - return PIX_ERR; - if ( pm_readbiglong( in, &(hP->ras_height) ) == -1 ) - return PIX_ERR; - if ( pm_readbiglong( in, &(hP->ras_depth) ) == -1 ) - return PIX_ERR; - if ( pm_readbiglong( in, &(hP->ras_length) ) == -1 ) - return PIX_ERR; - if ( pm_readbiglong( in, &(hP->ras_type) ) == -1 ) - return PIX_ERR; - if ( pm_readbiglong( in, &(hP->ras_maptype) ) == -1 ) - return PIX_ERR; - if ( pm_readbiglong( in, &(hP->ras_maplength) ) == -1 ) - return PIX_ERR; - return 0; - } - -int -pr_load_colormap( in, hP, colormap ) - FILE* in; - struct rasterfile* hP; - colormap_t* colormap; - { - if ( colormap == NULL || hP->ras_maptype == RMT_NONE ) - { - int i; - - for ( i = 0; i < hP->ras_maplength; ++i ) - if ( getc( in ) == EOF ) - return PIX_ERR; - } - else - { - colormap->type = hP->ras_maptype; - switch ( hP->ras_maptype ) - { - case RMT_EQUAL_RGB: - colormap->length = hP->ras_maplength / 3; - colormap->map[0] = (unsigned char*) malloc( colormap->length ); - if ( colormap->map[0] == NULL ) - return PIX_ERR; - colormap->map[1] = (unsigned char*) malloc( colormap->length ); - if ( colormap->map[1] == NULL ) - { - free( colormap->map[0] ); - return PIX_ERR; - } - colormap->map[2] = (unsigned char*) malloc( colormap->length ); - if ( colormap->map[2] == NULL ) - { - free( colormap->map[0] ); - free( colormap->map[1] ); - return PIX_ERR; - } - if ( fread( colormap->map[0], 1, colormap->length, in ) != (size_t) colormap->length || - fread( colormap->map[1], 1, colormap->length, in ) != (size_t) colormap->length || - fread( colormap->map[2], 1, colormap->length, in ) != (size_t) colormap->length ) - { - free( colormap->map[0] ); - free( colormap->map[1] ); - free( colormap->map[2] ); - return PIX_ERR; - } - break; - - case RMT_RAW: - colormap->length = hP->ras_maplength; - colormap->map[0] = (unsigned char*) malloc( colormap->length ); - if ( colormap->map[0] == NULL ) - return PIX_ERR; - colormap->map[2] = colormap->map[1] = colormap->map[0]; - if ( fread( colormap->map[0], 1, hP->ras_maplength, in ) != (size_t) hP->ras_maplength ) - { - free( colormap->map[0] ); - return PIX_ERR; - } - break; - - default: - pm_error( "unknown colormap type" ); - } - } - return 0; - } - -struct pixrect* -pr_load_image( in, hP, colormap ) - FILE* in; - struct rasterfile* hP; - colormap_t* colormap; - { - struct pixrect* p; - unsigned char* beimage; - register unsigned char* bep; - register unsigned char* bp; - register unsigned char c; - int i; - register int j, count; - - p = mem_create( hP->ras_width, hP->ras_height, hP->ras_depth ); - if ( p == NULL ) - return NULL; - - switch ( hP->ras_type ) - { - case RT_OLD: - pm_error( "old rasterfile type is not supported" ); - - case RT_FORMAT_TIFF: - pm_error( "tiff rasterfile type is not supported" ); - - case RT_FORMAT_IFF: - pm_error( "iff rasterfile type is not supported" ); - - case RT_EXPERIMENTAL: - pm_error( "experimental rasterfile type is not supported" ); - - case RT_STANDARD: - case RT_FORMAT_RGB: - /* Ignore hP->ras_length. */ - i = p->pr_size.y * p->pr_data->md_linebytes; - if ( fread( p->pr_data->md_image, 1, i, in ) != (size_t) i ) - { - mem_free( p ); - return NULL; - } - break; - - case RT_BYTE_ENCODED: - beimage = (unsigned char*) malloc( hP->ras_length ); - if ( beimage == NULL ) - { - mem_free( p ); - return NULL; - } - if ( fread( beimage, 1, hP->ras_length, in ) != (size_t) hP->ras_length ) - { - mem_free( p ); - free( beimage ); - return NULL; - } - bep = beimage; - bp = p->pr_data->md_image; - for ( i = 0; i < hP->ras_length; ) - { - c = *bep++; - if ( c == 128 ) - { - count = ( *bep++ ) + 1; - if ( count == 1 ) - { - *bp++ = 128; - i += 2; - } - else - { - c = *bep++; - for ( j = 0; j < count; ++j ) - *bp++ = c; - i += 3; - } - } - else - { - *bp++ = c; - ++i; - } - } - free( beimage ); - break; - - default: - pm_error( "unknown rasterfile type" ); - } - - return p; - } diff --git a/panda/src/pnm/libppm.h b/panda/src/pnm/libppm.h deleted file mode 100644 index 40d0ca6dc9..0000000000 --- a/panda/src/pnm/libppm.h +++ /dev/null @@ -1,11 +0,0 @@ -/* libppm.h - internal header file for libppm portable pixmap library -*/ - -#ifndef _LIBPPM_H_ -#define _LIBPPM_H_ - -/* Here are some routines internal to the ppm library. */ - -EXPCL_PANDA void ppm_readppminitrest( FILE* file, int* colsP, int* rowsP, pixval* maxvalP ); - -#endif /*_LIBPPM_H_*/ diff --git a/panda/src/pnm/libppm1.c b/panda/src/pnm/libppm1.c deleted file mode 100644 index ee20595155..0000000000 --- a/panda/src/pnm/libppm1.c +++ /dev/null @@ -1,195 +0,0 @@ -/* libppm1.c - ppm utility library part 1 -** -** Copyright (C) 1989 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include "ppm.h" -#include "libppm.h" -#include "pgm.h" -#include "libpgm.h" -#include "pbm.h" -#include "libpbm.h" - -void -ppm_init( argcP, argv ) - int* argcP; - char* argv[]; - { - pgm_init( argcP, argv ); - } - -void -ppm_readppminitrest( file, colsP, rowsP, maxvalP ) - FILE* file; - int* colsP; - int* rowsP; - pixval* maxvalP; - { - int maxval; - - /* Read size. */ - *colsP = pbm_getint( file ); - *rowsP = pbm_getint( file ); - - /* Read maxval. */ - maxval = pbm_getint( file ); - if ( maxval > PPM_MAXMAXVAL ) - pm_error( -"maxval is too large - try reconfiguring with PGM_BIGGRAYS\n or without PPM_PACKCOLORS" ); - *maxvalP = maxval; - } - -pixval ppm_pbmmaxval = 1; - -void -ppm_readppminit( file, colsP, rowsP, maxvalP, formatP ) - FILE* file; - int* colsP; - int* rowsP; - int* formatP; - pixval* maxvalP; - { - /* Check magic number. */ - *formatP = pbm_readmagicnumber( file ); - switch ( PPM_FORMAT_TYPE(*formatP) ) - { - case PPM_TYPE: - ppm_readppminitrest( file, colsP, rowsP, maxvalP ); - break; - - case PGM_TYPE: - pgm_readpgminitrest( file, colsP, rowsP, maxvalP ); - break; - - case PBM_TYPE: - pbm_readpbminitrest( file, colsP, rowsP ); - *maxvalP = ppm_pbmmaxval; - break; - - default: - pm_error( "bad magic number - not a ppm, pgm, or pbm file" ); - } - } - -#if __STDC__ -void -ppm_readppmrow( FILE* file, pixel* pixelrow, int cols, pixval maxval, int format ) -#else /*__STDC__*/ -void -ppm_readppmrow( file, pixelrow, cols, maxval, format ) - FILE* file; - pixel* pixelrow; - int cols, format; - pixval maxval; -#endif /*__STDC__*/ - { - register int col; - register pixel* pP; - register pixval r, g, b; - gray* grayrow; - register gray* gP; - bit* bitrow; - register bit* bP; - - switch ( format ) - { - case PPM_FORMAT: - for ( col = 0, pP = pixelrow; col < cols; ++col, ++pP ) - { - r = pbm_getint( file ); -#ifdef DEBUG - if ( r > maxval ) - pm_error( "r value out of bounds (%u > %u)", r, maxval ); -#endif /*DEBUG*/ - g = pbm_getint( file ); -#ifdef DEBUG - if ( g > maxval ) - pm_error( "g value out of bounds (%u > %u)", g, maxval ); -#endif /*DEBUG*/ - b = pbm_getint( file ); -#ifdef DEBUG - if ( b > maxval ) - pm_error( "b value out of bounds (%u > %u)", b, maxval ); -#endif /*DEBUG*/ - PPM_ASSIGN( *pP, r, g, b ); - } - break; - - case RPPM_FORMAT: - for ( col = 0, pP = pixelrow; col < cols; ++col, ++pP ) - { - r = pbm_getrawbyte( file ); -#ifdef DEBUG - if ( r > maxval ) - pm_error( "r value out of bounds (%u > %u)", r, maxval ); -#endif /*DEBUG*/ - g = pbm_getrawbyte( file ); -#ifdef DEBUG - if ( g > maxval ) - pm_error( "g value out of bounds (%u > %u)", g, maxval ); -#endif /*DEBUG*/ - b = pbm_getrawbyte( file ); -#ifdef DEBUG - if ( b > maxval ) - pm_error( "b value out of bounds (%u > %u)", b, maxval ); -#endif /*DEBUG*/ - PPM_ASSIGN( *pP, r, g, b ); - } - break; - - case PGM_FORMAT: - case RPGM_FORMAT: - grayrow = pgm_allocrow( cols ); - pgm_readpgmrow( file, grayrow, cols, maxval, format ); - for ( col = 0, gP = grayrow, pP = pixelrow; col < cols; ++col, ++gP, ++pP ) - { - r = *gP; - PPM_ASSIGN( *pP, r, r, r ); - } - pgm_freerow( grayrow ); - break; - - case PBM_FORMAT: - case RPBM_FORMAT: - bitrow = pbm_allocrow( cols ); - pbm_readpbmrow( file, bitrow, cols, format ); - for ( col = 0, bP = bitrow, pP = pixelrow; col < cols; ++col, ++bP, ++pP ) - { - r = ( *bP == PBM_WHITE ) ? maxval : 0; - PPM_ASSIGN( *pP, r, r, r ); - } - pbm_freerow( bitrow ); - break; - - default: - pm_error( "can't happen" ); - } - } - -pixel** -ppm_readppm( file, colsP, rowsP, maxvalP ) - FILE* file; - int* colsP; - int* rowsP; - pixval* maxvalP; - { - pixel** pixels; - int row; - int format; - - ppm_readppminit( file, colsP, rowsP, maxvalP, &format ); - - pixels = ppm_allocarray( *colsP, *rowsP ); - - for ( row = 0; row < *rowsP; ++row ) - ppm_readppmrow( file, pixels[row], *colsP, *maxvalP, format ); - - return pixels; - } diff --git a/panda/src/pnm/libppm2.c b/panda/src/pnm/libppm2.c deleted file mode 100644 index f58221016e..0000000000 --- a/panda/src/pnm/libppm2.c +++ /dev/null @@ -1,185 +0,0 @@ -/* libppm2.c - ppm utility library part 2 -** -** Copyright (C) 1989 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include "ppm.h" -#include "libppm.h" - -static void putus ARGS((unsigned short n, FILE* file)); - -static void ppm_writeppmrowplain ARGS((FILE* file, pixel* pixelrow, int cols, pixval maxval)); - -#ifdef PBMPLUS_RAWBITS -static void ppm_writeppmrowraw(FILE* file, pixel* pixelrow, int cols, pixval maxval); -#endif /* PBMPLUS_RAWBITS */ - -#if __STDC__ -void -ppm_writeppminit( FILE* file, int cols, int rows, pixval maxval, int forceplain ) -#else /*__STDC__*/ -void -ppm_writeppminit( file, cols, rows, maxval, forceplain ) - FILE* file; - int cols, rows; - pixval maxval; - int forceplain; -#endif /*__STDC__*/ - { -#ifdef PBMPLUS_RAWBITS - if ( maxval <= 255 && ! forceplain ) { - fprintf( - file, "%c%c\n%d %d\n%d\n", PPM_MAGIC1, RPPM_MAGIC2, - cols, rows, maxval ); -#ifdef VMS - set_outfile_binary(); -#endif - } - else - fprintf( - file, "%c%c\n%d %d\n%d\n", PPM_MAGIC1, PPM_MAGIC2, - cols, rows, maxval ); -#else /*PBMPLUS_RAWBITS*/ - fprintf( - file, "%c%c\n%d %d\n%d\n", PPM_MAGIC1, PPM_MAGIC2, - cols, rows, maxval ); -#endif /*PBMPLUS_RAWBITS*/ - } - -static void -putus(unsigned short n, FILE* file) - { - if ( n >= 10 ) - putus( (unsigned short)(n / 10), file ); - (void) putc( n % 10 + '0', file ); - } - -#ifdef PBMPLUS_RAWBITS -static void -ppm_writeppmrowraw (FILE* file,pixel* pixelrow,int cols,pixval maxval) - { - register int col; - register pixel* pP; - register pixval val; - - for ( col = 0, pP = pixelrow; col < cols; ++col, ++pP ) - { - val = PPM_GETR( *pP ); -#ifdef DEBUG - if ( val > maxval ) - pm_error( "r value out of bounds (%u > %u)", val, maxval ); -#endif /*DEBUG*/ - (void) putc( val, file ); - val = PPM_GETG( *pP ); -#ifdef DEBUG - if ( val > maxval ) - pm_error( "g value out of bounds (%u > %u)", val, maxval ); -#endif /*DEBUG*/ - (void) putc( val, file ); - val = PPM_GETB( *pP ); -#ifdef DEBUG - if ( val > maxval ) - pm_error( "b value out of bounds (%u > %u)", val, maxval ); -#endif /*DEBUG*/ - (void) putc( val, file ); - } - } -#endif /*PBMPLUS_RAWBITS*/ - -static void -ppm_writeppmrowplain(FILE* file,pixel* pixelrow,int cols,pixval maxval) - { - register int col, charcount; - register pixel* pP; - register pixval val; - - charcount = 0; - for ( col = 0, pP = pixelrow; col < cols; ++col, ++pP ) - { - if ( charcount >= 65 ) - { - (void) putc( '\n', file ); - charcount = 0; - } - else if ( charcount > 0 ) - { - (void) putc( ' ', file ); - (void) putc( ' ', file ); - charcount += 2; - } - val = PPM_GETR( *pP ); -#ifdef DEBUG - if ( val > maxval ) - pm_error( "r value out of bounds (%u > %u)", val, maxval ); -#endif /*DEBUG*/ - putus( val, file ); - (void) putc( ' ', file ); - val = PPM_GETG( *pP ); -#ifdef DEBUG - if ( val > maxval ) - pm_error( "g value out of bounds (%u > %u)", val, maxval ); -#endif /*DEBUG*/ - putus( val, file ); - (void) putc( ' ', file ); - val = PPM_GETB( *pP ); -#ifdef DEBUG - if ( val > maxval ) - pm_error( "b value out of bounds (%u > %u)", val, maxval ); -#endif /*DEBUG*/ - putus( val, file ); - charcount += 11; - } - if ( charcount > 0 ) - (void) putc( '\n', file ); - } - -#if __STDC__ -void -ppm_writeppmrow( FILE* file, pixel* pixelrow, int cols, pixval maxval, int forceplain ) -#else /*__STDC__*/ -void -ppm_writeppmrow( file, pixelrow, cols, maxval, forceplain ) - FILE* file; - pixel* pixelrow; - int cols; - pixval maxval; - int forceplain; -#endif /*__STDC__*/ - { -#ifdef PBMPLUS_RAWBITS - if ( maxval <= 255 && ! forceplain ) - ppm_writeppmrowraw( file, pixelrow, cols, maxval ); - else - ppm_writeppmrowplain( file, pixelrow, cols, maxval ); -#else /*PBMPLUS_RAWBITS*/ - ppm_writeppmrowplain( file, pixelrow, cols, maxval ); -#endif /*PBMPLUS_RAWBITS*/ - } - -#if __STDC__ -void -ppm_writeppm( FILE* file, pixel** pixels, int cols, int rows, pixval maxval, int forceplain ) -#else /*__STDC__*/ -void -ppm_writeppm( file, pixels, cols, rows, maxval, forceplain ) - FILE* file; - pixel** pixels; - int cols, rows; - pixval maxval; - int forceplain; -#endif /*__STDC__*/ - { - int row; - - ppm_writeppminit( file, cols, rows, maxval, forceplain ); - - for ( row = 0; row < rows; ++row ) - ppm_writeppmrow( file, pixels[row], cols, maxval, forceplain ); - } diff --git a/panda/src/pnm/libppm4.c b/panda/src/pnm/libppm4.c deleted file mode 100644 index 802680be1a..0000000000 --- a/panda/src/pnm/libppm4.c +++ /dev/null @@ -1,330 +0,0 @@ -/* libppm4.c - ppm utility library part 4 -** -** Copyright (C) 1989 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include -#include -#include "ppm.h" - -static void canonstr ARGS((char* str)); -static long rgbnorm ARGS((long rgb, long lmaxval, int n, char* colorname)); -static void -canonstr( str ) - char* str; - { - while ( *str != '\0' ) - { - if ( *str == ' ' ) - { - (void) strcpy( str, &(str[1]) ); - continue; - } - if ( isupper( *str ) ) - *str = tolower( *str ); - ++str; - } - } - -static long -rgbnorm( rgb, lmaxval, n, colorname ) - long rgb, lmaxval; - int n; - char* colorname; - { - switch ( n ) - { - case 1: - if ( lmaxval != 15 ) - rgb = rgb * lmaxval / 15; - break; - case 2: - if ( lmaxval != 255 ) - rgb = rgb * lmaxval / 255; - break; - case 3: - if ( lmaxval != 4095 ) - rgb = rgb * lmaxval / 4095; - break; - case 4: - if ( lmaxval != 65535L ) - rgb = rgb * lmaxval / 65535L; - break; - default: - pm_error( "invalid color specifier - \"%s\"", colorname ); - } - return rgb; - } - -#if __STDC__ -pixel -ppm_parsecolor( char* colorname, pixval maxval ) -#else /*__STDC__*/ -pixel -ppm_parsecolor( colorname, maxval ) - char* colorname; - pixval maxval; -#endif /*__STDC__*/ - { - int hexit[256], i; - pixel p; - long lmaxval, r, g, b; - char* inval = "invalid color specifier - \"%s\""; - - for ( i = 0; i < 256; ++i ) - hexit[i] = 1234567890; - hexit['0'] = 0; - hexit['1'] = 1; - hexit['2'] = 2; - hexit['3'] = 3; - hexit['4'] = 4; - hexit['5'] = 5; - hexit['6'] = 6; - hexit['7'] = 7; - hexit['8'] = 8; - hexit['9'] = 9; - hexit['a'] = hexit['A'] = 10; - hexit['b'] = hexit['B'] = 11; - hexit['c'] = hexit['C'] = 12; - hexit['d'] = hexit['D'] = 13; - hexit['e'] = hexit['E'] = 14; - hexit['f'] = hexit['F'] = 15; - - lmaxval = maxval; - if ( strncmp( colorname, "rgb:", 4 ) == 0 ) - { - /* It's a new-X11-style hexadecimal rgb specifier. */ - char* cp; - - cp = colorname + 4; - r = g = b = 0; - for ( i = 0; *cp != '/'; ++i, ++cp ) - r = r * 16 + hexit[*cp]; - r = rgbnorm( r, lmaxval, i, colorname ); - for ( i = 0, ++cp; *cp != '/'; ++i, ++cp ) - g = g * 16 + hexit[*cp]; - g = rgbnorm( g, lmaxval, i, colorname ); - for ( i = 0, ++cp; *cp != '\0'; ++i, ++cp ) - b = b * 16 + hexit[*cp]; - b = rgbnorm( b, lmaxval, i, colorname ); - if ( r < 0 || r > lmaxval || g < 0 || g > lmaxval || b < 0 || b > lmaxval ) - pm_error( inval, colorname ); - } - else if ( strncmp( colorname, "rgbi:", 5 ) == 0 ) - { - /* It's a new-X11-style decimal/float rgb specifier. */ - float fr, fg, fb; - - if ( sscanf( colorname, "rgbi:%f/%f/%f", &fr, &fg, &fb ) != 3 ) - pm_error( inval, colorname ); - if ( fr < 0.0 || fr > 1.0 || fg < 0.0 || fg > 1.0 || fb < 0.0 || fb > 1.0 ) - pm_error( "invalid color specifier - \"%s\" - values must be between 0.0 and 1.0", colorname ); - r = fr * lmaxval; - g = fg * lmaxval; - b = fb * lmaxval; - } - else if ( colorname[0] == '#' ) - { - /* It's an old-X11-style hexadecimal rgb specifier. */ - switch ( strlen( colorname ) ) - { - case 4: - r = hexit[colorname[1]]; - g = hexit[colorname[2]]; - b = hexit[colorname[3]]; - r = rgbnorm( r, lmaxval, 1, colorname ); - g = rgbnorm( g, lmaxval, 1, colorname ); - b = rgbnorm( b, lmaxval, 1, colorname ); - break; - - case 7: - r = ( hexit[colorname[1]] << 4 ) + hexit[colorname[2]]; - g = ( hexit[colorname[3]] << 4 ) + hexit[colorname[4]]; - b = ( hexit[colorname[5]] << 4 ) + hexit[colorname[6]]; - r = rgbnorm( r, lmaxval, 2, colorname ); - g = rgbnorm( g, lmaxval, 2, colorname ); - b = rgbnorm( b, lmaxval, 2, colorname ); - break; - - case 10: - r = ( hexit[colorname[1]] << 8 ) + ( hexit[colorname[2]] << 4 ) + - hexit[colorname[3]]; - g = ( hexit[colorname[4]] << 8 ) + ( hexit[colorname[5]] << 4 ) + - hexit[colorname[6]]; - b = ( hexit[colorname[7]] << 8 ) + ( hexit[colorname[8]] << 4 ) + - hexit[colorname[9]]; - r = rgbnorm( r, lmaxval, 3, colorname ); - g = rgbnorm( g, lmaxval, 3, colorname ); - b = rgbnorm( b, lmaxval, 3, colorname ); - break; - - case 13: - r = ( hexit[colorname[1]] << 12 ) + ( hexit[colorname[2]] << 8 ) + - ( hexit[colorname[3]] << 4 ) + hexit[colorname[4]]; - g = ( hexit[colorname[5]] << 12 ) + ( hexit[colorname[6]] << 8 ) + - ( hexit[colorname[7]] << 4 ) + hexit[colorname[8]]; - b = ( hexit[colorname[9]] << 12 ) + ( hexit[colorname[10]] << 8 ) + - ( hexit[colorname[11]] << 4 ) + hexit[colorname[12]]; - r = rgbnorm( r, lmaxval, 4, colorname ); - g = rgbnorm( g, lmaxval, 4, colorname ); - b = rgbnorm( b, lmaxval, 4, colorname ); - break; - - default: - pm_error( inval, colorname ); - } - if ( r < 0 || r > lmaxval || g < 0 || g > lmaxval || b < 0 || b > lmaxval ) - pm_error( inval, colorname ); - } - else if ( ( colorname[0] >= '0' && colorname[0] <= '9' ) || - colorname[0] == '.' ) - { - /* It's an old-style decimal/float rgb specifier. */ - float fr, fg, fb; - - if ( sscanf( colorname, "%f,%f,%f", &fr, &fg, &fb ) != 3 ) - pm_error( inval, colorname ); - if ( fr < 0.0 || fr > 1.0 || fg < 0.0 || fg > 1.0 || fb < 0.0 || fb > 1.0 ) - pm_error( "invalid color specifier - \"%s\" - values must be between 0.0 and 1.0", colorname ); - r = fr * lmaxval; - g = fg * lmaxval; - b = fb * lmaxval; - } - else - { - /* Must be a name from the X-style rgb file. */ -#ifndef RGB_DB - pm_error( "color names database required - please reconfigure with RGBDEF" ); -#else /*RGB_DB*/ - FILE* f; - char buf1[200], buf2[200]; - -#ifndef A_RGBENV - (void) sprintf( buf1, "%s.txt", RGB_DB ); - if ( ( f = fopen( buf1, "r" ) ) == NULL ) - pm_error( "can't open color names database - reconfigure with correct RGBDEF" ); -#else /* A_RGBENV */ - char *rgbdef; - if( (rgbdef = getenv(RGB_DB))==NULL ) - pm_error( "can't get path to color names database - %s not set", RGB_DB ); - if ( ( f = fopen( rgbdef, "r" ) ) == NULL ) - pm_error( "can't open color names database - set %s to correct path", RGB_DB ); -#endif /* A_RGBENV */ - canonstr( colorname ); - while ( fgets( buf1, sizeof(buf1), f ) != NULL ) - { - if ( sscanf( buf1, "%ld %ld %ld %[^\n]", &r, &g, &b, buf2 ) != 4 ) - { - pm_message( - "can't parse color names database line - \"%s\"", buf1 ); - continue; - } - canonstr( buf2 ); - if ( strcmp( colorname, buf2 ) == 0 ) - goto gotit; - } - (void) fclose( f ); - pm_error( "unknown color - \"%s\"", colorname ); - -gotit: - (void) fclose( f ); - /* Rescale from [0..255] if necessary. */ - if ( lmaxval != 255 ) - { - r = r * lmaxval / 255; - g = g * lmaxval / 255; - b = b * lmaxval / 255; - } -#endif /*RGB_DB*/ - } - - PPM_ASSIGN( p, r, g, b ); - return p; - } - -static char colorname[200]; - -#if __STDC__ -char* -ppm_colorname( pixel* colorP, pixval maxval, int hexok ) -#else /*__STDC__*/ -char* -ppm_colorname( colorP, maxval, hexok ) - pixel* colorP; - pixval maxval; - int hexok; -#endif /*__STDC__*/ - { - int r, g, b; -#ifdef RGB_DB - FILE* f; - char buf[200]; - int this_r, this_g, this_b; - int best_diff, this_diff; - char this_colorname[200]; -#ifdef A_RGBENV - char *rgbdef; -#endif /* A_RGBENV */ -#endif /*RGB_DB*/ - - if ( maxval == 255 ) - { - r = PPM_GETR( *colorP ); - g = PPM_GETG( *colorP ); - b = PPM_GETB( *colorP ); - } - else - { - r = (int) PPM_GETR( *colorP ) * 255 / (int) maxval; - g = (int) PPM_GETG( *colorP ) * 255 / (int) maxval; - b = (int) PPM_GETB( *colorP ) * 255 / (int) maxval; - } - -#ifdef RGB_DB -#ifndef A_RGBENV - (void) sprintf( buf, "%s.txt", RGB_DB ); - if ( ( f = fopen( buf, "r" ) ) == NULL ) - pm_error( "can't open color names database - reconfigure with correct RGBDEF" ); -#else /* A_RGBENV */ - if( (rgbdef = getenv(RGB_DB))==NULL ) - pm_error( "can't get path to color names database - %s not set", RGB_DB ); - if ( ( f = fopen( rgbdef, "r" ) ) == NULL ) - pm_error( "can't open color names database - set %s to correct path", RGB_DB ); -#endif /* A_RGBENV */ - best_diff = 32767; - while ( fgets( buf, sizeof(buf), f ) != NULL ) - { - if ( sscanf( buf, "%d %d %d %[^\n]", &this_r, &this_g, &this_b, - this_colorname ) != 4 ) - { - pm_message( - "can't parse color names database line - \"%s\"", - buf ); - continue; - } - this_diff = abs( r - this_r ) + abs( g - this_g ) + abs( b - this_b ); - if ( this_diff < best_diff ) - { - best_diff = this_diff; - (void) strcpy( colorname, this_colorname ); - } - } - (void) fclose( f ); - if ( best_diff != 32767 && ( best_diff == 0 || ! hexok ) ) - return colorname; -#endif /*RGB_DB*/ - - /* Color lookup failed; generate an X11-style hex specifier. */ - if ( ! hexok ) - pm_error( - "color names database required - please reconfigure with RGBDEF" ); - sprintf( colorname, "#%02x%02x%02x", r, g, b ); - return colorname; - } diff --git a/panda/src/pnm/libppm5.c b/panda/src/pnm/libppm5.c deleted file mode 100644 index ed6a531b16..0000000000 --- a/panda/src/pnm/libppm5.c +++ /dev/null @@ -1,697 +0,0 @@ -/* libppm5.c - ppm utility library part 5 -** -** This library module contains the ppmdraw routines. -** -** Copyright (C) 1989, 1991 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#include -#include -#include "ppm.h" -#include "ppmdraw.h" - -#define DDA_SCALE 8192 - -#if __STDC__ -void -ppmd_point_drawproc( pixel** pixels, int cols, int rows, pixval maxval, int x, int y, char* clientdata ) -#else /*__STDC__*/ -void -ppmd_point_drawproc( pixels, cols, rows, maxval, x, y, clientdata ) - pixel** pixels; - int cols, rows, x, y; - pixval maxval; - char* clientdata; -#endif /*__STDC__*/ - { - if ( x >= 0 && x < cols && y >= 0 && y < rows ) - pixels[y][x] = *( (pixel*) clientdata ); - } - - -/* Simple fill routine. */ - -#if __STDC__ -void -ppmd_filledrectangle( pixel** pixels, int cols, int rows, pixval maxval, int x, int y, int width, int height, void (*drawprocP)(pixel**, int, int, pixval, int, int, char*), char* clientdata ) -#else /*__STDC__*/ -void -ppmd_filledrectangle( pixels, cols, rows, maxval, x, y, width, height, drawprocP, clientdata ) - pixel** pixels; - int cols, rows, x, y, width, height; - pixval maxval; - void (*drawprocP)(); - char* clientdata; -#endif /*__STDC__*/ - { - register int cx, cy, cwidth, cheight, col, row; - - /* Clip. */ - cx = x; - cy = y; - cwidth = width; - cheight = height; - if ( cx < 0 ) - { - cx = 0; - cwidth += x; - } - if ( cy < 0 ) - { - cy = 0; - cheight += y; - } - if ( cx + cwidth > cols ) - cwidth = cols - cx; - if ( cy + cheight > rows ) - cheight = rows - cy; - - /* Draw. */ - for ( row = cy; row < cy + cheight; ++row ) - for ( col = cx; col < cx + cwidth; ++col ) - if ( drawprocP == PPMD_NULLDRAWPROC ) - pixels[row][col] = *( (pixel*) clientdata ); - else - (*drawprocP)( - pixels, cols, rows, maxval, col, row, clientdata ); - } - - -/* Outline drawing stuff. */ - -static int ppmd_linetype = PPMD_LINETYPE_NORMAL; - -int -ppmd_setlinetype( type ) - int type; - { - int old; - - old = ppmd_linetype; - ppmd_linetype = type; - return old; - } - -static int ppmd_lineclip = 1; - -int -ppmd_setlineclip( clip ) - int clip; - { - int old; - - old = ppmd_lineclip; - ppmd_lineclip = clip; - return old; - } - -#if __STDC__ -void -ppmd_line( pixel** pixels, int cols, int rows, pixval maxval, int x0, int y0, int x1, int y1, void (*drawprocP)(pixel**, int, int, pixval, int, int, char*), char* clientdata ) -#else /*__STDC__*/ -void -ppmd_line( pixels, cols, rows, maxval, x0, y0, x1, y1, drawprocP, clientdata ) - pixel** pixels; - int cols, rows, x0, y0, x1, y1; - pixval maxval; - void (*drawprocP)(); - char* clientdata; -#endif /*__STDC__*/ - { - register int cx0, cy0, cx1, cy1; - - /* Special case zero-length lines. */ - if ( x0 == x1 && y0 == y1 ) - { - if ( ( ! ppmd_lineclip ) || - ( x0 >= 0 && x0 < cols && y0 >= 0 && y0 < rows ) ) - if ( drawprocP == PPMD_NULLDRAWPROC ) - ppmd_point_drawproc( - pixels, cols, rows, maxval, x0, y0, clientdata ); - else - (*drawprocP)( pixels, cols, rows, maxval, x0, y0, clientdata ); - return; - } - - /* Clip. */ - cx0 = x0; - cy0 = y0; - cx1 = x1; - cy1 = y1; - if ( ppmd_lineclip ) - { - if ( cx0 < 0 ) - { - if ( cx1 < 0 ) return; - cy0 = cy0 + ( cy1 - cy0 ) * ( -cx0 ) / ( cx1 - cx0 ); - cx0 = 0; - } - else if ( cx0 >= cols ) - { - if ( cx1 >= cols ) return; - cy0 = cy0 + ( cy1 - cy0 ) * ( cols - 1 - cx0 ) / ( cx1 - cx0 ); - cx0 = cols - 1; - } - if ( cy0 < 0 ) - { - if ( cy1 < 0 ) return; - cx0 = cx0 + ( cx1 - cx0 ) * ( -cy0 ) / ( cy1 - cy0 ); - cy0 = 0; - } - else if ( cy0 >= rows ) - { - if ( cy1 >= rows ) return; - cx0 = cx0 + ( cx1 - cx0 ) * ( rows - 1 - cy0 ) / ( cy1 - cy0 ); - cy0 = rows - 1; - } - if ( cx1 < 0 ) - { - cy1 = cy1 + ( cy0 - cy1 ) * ( -cx1 ) / ( cx0 - cx1 ); - cx1 = 0; - } - else if ( cx1 >= cols ) - { - cy1 = cy1 + ( cy0 - cy1 ) * ( cols - 1 - cx1 ) / ( cx0 - cx1 ); - cx1 = cols - 1; - } - if ( cy1 < 0 ) - { - cx1 = cx1 + ( cx0 - cx1 ) * ( -cy1 ) / ( cy0 - cy1 ); - cy1 = 0; - } - else if ( cy1 >= rows ) - { - cx1 = cx1 + ( cx0 - cx1 ) * ( rows - 1 - cy1 ) / ( cy0 - cy1 ); - cy1 = rows - 1; - } - - /* Check again for zero-length lines. */ - if ( cx0 == cx1 && cy0 == cy1 ) - { - if ( drawprocP == PPMD_NULLDRAWPROC ) - ppmd_point_drawproc( - pixels, cols, rows, maxval, cx0, cy0, clientdata ); - else - (*drawprocP)( - pixels, cols, rows, maxval, cx0, cy0, clientdata ); - return; - } - } - - /* Draw, using a simple DDA. */ - if ( abs( cx1 - cx0 ) > abs( cy1 - cy0 ) ) - { /* Loop over X domain. */ - register long dy, srow; - register int dx, col, row, prevrow; - - if ( cx1 > cx0 ) - dx = 1; - else - dx = -1; - dy = ( cy1 - cy0 ) * DDA_SCALE / abs( cx1 - cx0 ); - prevrow = row = cy0; - srow = row * DDA_SCALE + DDA_SCALE / 2; - col = cx0; - for ( ; ; ) - { - if ( ppmd_linetype == PPMD_LINETYPE_NODIAGS && row != prevrow ) - { - if ( drawprocP == PPMD_NULLDRAWPROC ) - pixels[prevrow][col] = *( (pixel*) clientdata ); - else - (*drawprocP)( - pixels, cols, rows, maxval, col, prevrow, clientdata ); - prevrow = row; - } - if ( drawprocP == PPMD_NULLDRAWPROC ) - pixels[row][col] = *( (pixel*) clientdata ); - else - (*drawprocP)( - pixels, cols, rows, maxval, col, row, clientdata ); - if ( col == cx1 ) - break; - srow += dy; - row = srow / DDA_SCALE; - col += dx; - } - } - else - { /* Loop over Y domain. */ - register long dx, scol; - register int dy, col, row, prevcol; - - if ( cy1 > cy0 ) - dy = 1; - else - dy = -1; - dx = ( cx1 - cx0 ) * DDA_SCALE / abs( cy1 - cy0 ); - row = cy0; - prevcol = col = cx0; - scol = col * DDA_SCALE + DDA_SCALE / 2; - for ( ; ; ) - { - if ( ppmd_linetype == PPMD_LINETYPE_NODIAGS && col != prevcol ) - { - if ( drawprocP == PPMD_NULLDRAWPROC ) - pixels[row][prevcol] = *( (pixel*) clientdata ); - else - (*drawprocP)( - pixels, cols, rows, maxval, prevcol, row, clientdata ); - prevcol = col; - } - if ( drawprocP == PPMD_NULLDRAWPROC ) - pixels[row][col] = *( (pixel*) clientdata ); - else - (*drawprocP)( - pixels, cols, rows, maxval, col, row, clientdata ); - if ( row == cy1 ) - break; - row += dy; - scol += dx; - col = scol / DDA_SCALE; - } - } - } - -#define SPLINE_THRESH 3 -#if __STDC__ -void -ppmd_spline3( pixel** pixels, int cols, int rows, pixval maxval, int x0, int y0, int x1, int y1, int x2, int y2, void (*drawprocP)(pixel**, int, int, pixval, int, int, char*), char* clientdata ) -#else /*__STDC__*/ -void -ppmd_spline3( pixels, cols, rows, maxval, x0, y0, x1, y1, x2, y2, drawprocP, clientdata ) - pixel** pixels; - int cols, rows, x0, y0, x1, y1, x2, y2; - pixval maxval; - void (*drawprocP)(); - char* clientdata; -#endif /*__STDC__*/ - { - register int xa, ya, xb, yb, xc, yc, xp, yp; - - xa = ( x0 + x1 ) / 2; - ya = ( y0 + y1 ) / 2; - xc = ( x1 + x2 ) / 2; - yc = ( y1 + y2 ) / 2; - xb = ( xa + xc ) / 2; - yb = ( ya + yc ) / 2; - - xp = ( x0 + xb ) / 2; - yp = ( y0 + yb ) / 2; - if ( abs( xa - xp ) + abs( ya - yp ) > SPLINE_THRESH ) - ppmd_spline3( - pixels, cols, rows, maxval, x0, y0, xa, ya, xb, yb, drawprocP, - clientdata ); - else - ppmd_line( - pixels, cols, rows, maxval, x0, y0, xb, yb, drawprocP, clientdata ); - - xp = ( x2 + xb ) / 2; - yp = ( y2 + yb ) / 2; - if ( abs( xc - xp ) + abs( yc - yp ) > SPLINE_THRESH ) - ppmd_spline3( - pixels, cols, rows, maxval, xb, yb, xc, yc, x2, y2, drawprocP, - clientdata ); - else - ppmd_line( - pixels, cols, rows, maxval, xb, yb, x2, y2, drawprocP, clientdata ); - } - -#if __STDC__ -void -ppmd_polyspline( pixel** pixels, int cols, int rows, pixval maxval, int x0, int y0, int nc, int* xc, int* yc, int x1, int y1, void (*drawprocP)(pixel**, int, int, pixval, int, int, char*), char* clientdata ) -#else /*__STDC__*/ -void -ppmd_polyspline( pixels, cols, rows, maxval, x0, y0, nc, xc, yc, x1, y1, drawprocP, clientdata ) - pixel** pixels; - int cols, rows, x0, y0, nc, x1, y1; - int* xc; - int* yc; - pixval maxval; - void (*drawprocP)(); - char* clientdata; -#endif /*__STDC__*/ - { - register int i, x, y, xn, yn; - - x = x0; - y = y0; - for ( i = 0; i < nc - 1; ++i ) - { - xn = ( xc[i] + xc[i + 1] ) / 2; - yn = ( yc[i] + yc[i + 1] ) / 2; - ppmd_spline3( - pixels, cols, rows, maxval, x, y, xc[i], yc[i], xn, yn, drawprocP, - clientdata ); - x = xn; - y = yn; - } - ppmd_spline3( - pixels, cols, rows, maxval, x, y, xc[nc - 1], yc[nc - 1], x1, y1, - drawprocP, clientdata ); - } - -#if __STDC__ -void -ppmd_circle( pixel** pixels, int cols, int rows, pixval maxval, int cx, int cy, int radius, void (*drawprocP)(pixel**, int, int, pixval, int, int, char*), char* clientdata ) -#else /*__STDC__*/ -void -ppmd_circle( pixels, cols, rows, maxval, cx, cy, radius, drawprocP, clientdata ) - pixel** pixels; - int cols, rows, cx, cy, radius; - pixval maxval; - void (*drawprocP)(); - char* clientdata; -#endif /*__STDC__*/ - { - register int x0, y0, x, y, prevx, prevy, nopointsyet; - register long sx, sy, e; - - x0 = x = radius; - y0 = y = 0; - sx = x * DDA_SCALE + DDA_SCALE / 2; - sy = y * DDA_SCALE + DDA_SCALE / 2; - e = DDA_SCALE / radius; - if ( drawprocP == PPMD_NULLDRAWPROC ) - pixels[y + cy][x + cx] = *( (pixel*) clientdata ); - else - (*drawprocP)( pixels, cols, rows, maxval, x + cx, y + cy, clientdata ); - nopointsyet = 1; - do - { - prevx = x; - prevy = y; - sx += e * sy / DDA_SCALE; - sy -= e * sx / DDA_SCALE; - x = sx / DDA_SCALE; - y = sy / DDA_SCALE; - if ( x != prevx || y != prevy ) - { - nopointsyet = 0; - if ( drawprocP == PPMD_NULLDRAWPROC ) - pixels[y + cy][x + cx] = *( (pixel*) clientdata ); - else - (*drawprocP)( - pixels, cols, rows, maxval, x + cx, y + cy, clientdata ); - } - } - while ( nopointsyet || x != x0 || y != y0 ); - } - - -/* Arbitrary fill stuff. */ - -typedef struct - { - short x; - short y; - short edge; - } coord; -typedef struct - { - int n; - int size; - int curedge; - int segstart; - int ydir; - int startydir; - coord* coords; - } fillobj; - -#define SOME 1000 - -static int oldclip; - -char* -ppmd_fill_init( ) - { - fillobj* fh; - - fh = (fillobj*) malloc( sizeof(fillobj) ); - if ( fh == 0 ) - pm_error( "out of memory allocating a fillhandle" ); - fh->n = 0; - fh->coords = (coord*) malloc( SOME * sizeof(coord) ); - if ( fh->coords == 0 ) - pm_error( "out of memory allocating a fillhandle" ); - fh->size = SOME; - fh->curedge = 0; - - /* Turn off line clipping. */ - oldclip = ppmd_setlineclip( 0 ); - - return (char*) fh; - } - -#if __STDC__ -void -ppmd_fill_drawproc( pixel** pixels, int cols, int rows, pixval maxval, int x, int y, char* clientdata ) -#else /*__STDC__*/ -void -ppmd_fill_drawproc( pixels, cols, rows, maxval, x, y, clientdata ) - pixel** pixels; - int cols, rows, x, y; - pixval maxval; - char* clientdata; -#endif /*__STDC__*/ - { - register fillobj* fh; - register coord* cp; - register coord* ocp; - - fh = (fillobj*) clientdata; - - if ( fh->n > 0 ) - { - /* If these are the same coords we saved last time, don't bother. */ - ocp = &(fh->coords[fh->n - 1]); - if ( x == ocp->x && y == ocp->y ) - return; - } - - /* Ok, these are new; check if there's room for two more coords. */ - if ( fh->n + 1 >= fh->size ) - { - fh->size += SOME; - fh->coords = (coord*) realloc( - (char*) fh->coords, fh->size * sizeof(coord) ); - if ( fh->coords == 0 ) - pm_error( "out of memory enlarging a fillhandle" ); - } - - /* Check for extremum and set the edge number. */ - if ( fh->n == 0 ) - { /* Start first segment. */ - fh->segstart = fh->n; - fh->ydir = 0; - fh->startydir = 0; - } - else - { - register int dx, dy; - - dx = x - ocp->x; - dy = y - ocp->y; - if ( dx < -1 || dx > 1 || dy < -1 || dy > 1 ) - { /* Segment break. Close off old one. */ - if ( fh->startydir != 0 && fh->ydir != 0 ) - if ( fh->startydir == fh->ydir ) - { /* Oops, first edge and last edge are the same. - ** Renumber the first edge in the old segment. */ - register coord* fcp; - int oldedge; - - fcp = &(fh->coords[fh->segstart]); - oldedge = fcp->edge; - for ( ; fcp->edge == oldedge; ++fcp ) - fcp->edge = ocp->edge; - } - /* And start new segment. */ - ++(fh->curedge); - fh->segstart = fh->n; - fh->ydir = 0; - fh->startydir = 0; - } - else - { /* Segment continues. */ - if ( dy != 0 ) - { - if ( fh->ydir != 0 && fh->ydir != dy ) - { /* Direction changed. Insert a fake coord, old - ** position but new edge number. */ - ++(fh->curedge); - cp = &(fh->coords[fh->n]); - cp->x = ocp->x; - cp->y = ocp->y; - cp->edge = fh->curedge; - ++(fh->n); - } - fh->ydir = dy; - if ( fh->startydir == 0 ) - fh->startydir = dy; - } - } - } - - /* Save this coord. */ - cp = &(fh->coords[fh->n]); - cp->x = x; - cp->y = y; - cp->edge = fh->curedge; - ++(fh->n); - } - -static int -yx_compare(const void* v1,const void* v2) { - coord* c1 = (coord *)v1; - coord* c2 = (coord *)v2; - - if ( c1->y > c2->y ) - return 1; - if ( c1->y < c2->y ) - return -1; - if ( c1->x > c2->x ) - return 1; - if ( c1->x < c2->x ) - return -1; - return 0; - } - -#if __STDC__ -void -ppmd_fill( pixel** pixels, int cols, int rows, pixval maxval, char* fillhandle, void (*drawprocP)(pixel**, int, int, pixval, int, int, char*), char* clientdata ) -#else /*__STDC__*/ -void -ppmd_fill( pixels, cols, rows, maxval, fillhandle, drawprocP, clientdata ) - pixel** pixels; - int cols, rows; - pixval maxval; - char* fillhandle; - void (*drawprocP)(); - char* clientdata; -#endif /*__STDC__*/ - { - register fillobj* fh; - int pedge, eq; - register int i, leftside, edge, lx, rx, py; - register coord* cp; - - fh = (fillobj*) fillhandle; - - /* Close off final segment. */ - if ( fh->n > 0 && fh->startydir != 0 && fh->ydir != 0 ) - if ( fh->startydir == fh->ydir ) - { /* Oops, first edge and last edge are the same. */ - register coord* fcp; - int lastedge, oldedge; - - lastedge = fh->coords[fh->n - 1].edge; - fcp = &(fh->coords[fh->segstart]); - oldedge = fcp->edge; - for ( ; fcp->edge == oldedge; ++fcp ) - fcp->edge = lastedge; - } - - /* Restore clipping now. */ - (void) ppmd_setlineclip( oldclip ); - - /* Sort the coords by Y, secondarily by X. */ - qsort( (char*) fh->coords, fh->n, sizeof(coord), yx_compare ); - - /* Find equal coords with different edge numbers, and swap if necessary. */ - edge = -1; - for ( i = 0; i < fh->n; ++i ) - { - cp = &(fh->coords[i]); - if ( i > 1 && eq && cp->edge != edge && cp->edge == pedge ) - { /* Swap .-1 and .-2. */ - coord t; - - t = fh->coords[i-1]; - fh->coords[i-1] = fh->coords[i-2]; - fh->coords[i-2] = t; - } - if ( i > 0 ) - { - if ( cp->x == lx && cp->y == py ) - { - eq = 1; - if ( cp->edge != edge && cp->edge == pedge ) - { /* Swap . and .-1. */ - coord t; - - t = *cp; - *cp = fh->coords[i-1]; - fh->coords[i-1] = t; - } - } - else - eq = 0; - } - lx = cp->x; - py = cp->y; - pedge = edge; - edge = cp->edge; - } - - /* Ok, now run through the coords filling spans. */ - for ( i = 0; i < fh->n; ++i ) - { - cp = &(fh->coords[i]); - if ( i == 0 ) - { - lx = rx = cp->x; - py = cp->y; - edge = cp->edge; - leftside = 1; - } - else - { - if ( cp->y != py ) - { /* Row changed. Emit old span and start a new one. */ - ppmd_filledrectangle( - pixels, cols, rows, maxval, lx, py, rx - lx + 1, 1, - drawprocP, clientdata); - lx = rx = cp->x; - py = cp->y; - edge = cp->edge; - leftside = 1; - } - else - { - if ( cp->edge == edge ) - { /* Continuation of side. */ - rx = cp->x; - } - else - { /* Edge changed. Is it a span? */ - if ( leftside ) - { - rx = cp->x; - leftside = 0; - } - else - { /* Got a span to fill. */ - ppmd_filledrectangle( - pixels, cols, rows, maxval, lx, py, rx - lx + 1, - 1, drawprocP, clientdata); - lx = rx = cp->x; - leftside = 1; - } - edge = cp->edge; - } - } - } - } - - /* All done. Free up the fillhandle and leave. */ - free( fh->coords ); - free( fh ); - } diff --git a/panda/src/pnm/pbm.h b/panda/src/pnm/pbm.h deleted file mode 100644 index 8cdfaf044f..0000000000 --- a/panda/src/pnm/pbm.h +++ /dev/null @@ -1,49 +0,0 @@ -/* pbm.h - header file for libpbm portable bitmap library -*/ - -#ifndef _PBM_H_ -#define _PBM_H_ - -#include - -#include "pbmplus.h" - -typedef unsigned char bit; -#define PBM_WHITE 0 -#define PBM_BLACK 1 - - -/* Magic constants. */ - -#define PBM_MAGIC1 'P' -#define PBM_MAGIC2 '1' -#define RPBM_MAGIC2 '4' -#define PBM_FORMAT (PBM_MAGIC1 * 256 + PBM_MAGIC2) -#define RPBM_FORMAT (PBM_MAGIC1 * 256 + RPBM_MAGIC2) -#define PBM_TYPE PBM_FORMAT - - -/* Macro for turning a format number into a type number. */ - -#define PBM_FORMAT_TYPE(f) ((f) == PBM_FORMAT || (f) == RPBM_FORMAT ? PBM_TYPE : -1) - - -/* Declarations of routines. */ - -void pbm_init ARGS(( int* argcP, char* argv[] )); - -#define pbm_allocarray( cols, rows ) ((bit**) pm_allocarray( cols, rows, sizeof(bit) )) -#define pbm_allocrow( cols ) ((bit*) pm_allocrow( cols, sizeof(bit) )) -#define pbm_freearray( bits, rows ) pm_freearray( (char**) bits, rows ) -#define pbm_freerow( bitrow ) pm_freerow( (char*) bitrow ) - -bit** pbm_readpbm ARGS(( FILE* file, int* colsP, int* rowsP )); -void pbm_readpbminit ARGS(( FILE* file, int* colsP, int* rowsP, int* formatP )); -void pbm_readpbmrow ARGS(( FILE* file, bit* bitrow, int cols, int format )); -char* pm_read_unknown_size ARGS(( FILE* file, long* buf )); - -void pbm_writepbm ARGS(( FILE* file, bit** bits, int cols, int rows, int forceplain )); -void pbm_writepbminit ARGS(( FILE* file, int cols, int rows, int forceplain )); -void pbm_writepbmrow ARGS(( FILE* file, bit* bitrow, int cols, int forceplain )); - -#endif /*_PBM_H_*/ diff --git a/panda/src/pnm/pbmfont.h b/panda/src/pnm/pbmfont.h deleted file mode 100644 index d3fd311030..0000000000 --- a/panda/src/pnm/pbmfont.h +++ /dev/null @@ -1,27 +0,0 @@ -/* pbmfont.h - header file for font routines in libpbm -*/ - -struct glyph { - int width, height; - int x, y; - int xadd; - char* bmap; -}; - -struct font { - int maxwidth, maxheight; - int x, y; - struct glyph* glyph[256]; - /* for compatibility with old pbmtext routines */ - /* oldfont is 0 if the font is BDF derived */ - bit** oldfont; - int fcols, frows; -}; - -struct font* pbm_defaultfont ARGS(( char* which )); -struct font* pbm_dissectfont ARGS(( bit** font, int frows, int fcols )); -struct font* pbm_loadfont ARGS(( char* filename )); -struct font* pbm_loadpbmfont ARGS(( char* filename )); -struct font* pbm_loadbdffont ARGS(( char* filename )); -void pbm_dumpfont ARGS(( struct font* fn )); -int mk_argvn ARGS(( char* s, char* vec[], int max )); diff --git a/panda/src/pnm/pbmplus.h b/panda/src/pnm/pbmplus.h deleted file mode 100644 index 81823e6f06..0000000000 --- a/panda/src/pnm/pbmplus.h +++ /dev/null @@ -1,291 +0,0 @@ -/* pbmplus.h - header file for PBM, PGM, PPM, and PNM -** -** Copyright (C) 1988, 1989, 1991 by Jef Poskanzer. -** -** Permission to use, copy, modify, and distribute this software and its -** documentation for any purpose 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. This software is provided "as is" without express or -** implied warranty. -*/ - -#ifndef _PBMPLUS_H_ -#define _PBMPLUS_H_ - -#include - -#ifdef WIN32_VC -#define MSDOS -#endif - -#include -#include -#include -#include -#ifdef VMS -#include -#endif - -#if defined(USG) || defined(SVR4) || defined(VMS) -#define SYSV -#endif -#if ! ( defined(BSD) || defined(SYSV) || defined(MSDOS) || defined(AMIGA) ) -/* CONFIGURE: If your system is >= 4.2BSD, set the BSD option; if you're a -** System V site, set the SYSV option; if you're IBM-compatible, set MSDOS; -** and if you run on an Amiga, set AMIGA. If your compiler is ANSI C, you're -** probably better off setting SYSV - all it affects is string handling. -*/ -/*#define BSD*/ -#define SYSV -/* #define MSDOS */ -/* #define AMIGA */ -#endif - -/* CONFIGURE: If you have an X11-style rgb color names file, define its -** path here. This is used by PPM to parse color names into rgb values. -** If you don't have such a file, comment this out and use the alternative -** hex and decimal forms to specify colors (see ppm/pgmtoppm.1 for details). -*/ -#ifndef RGB_DB -#define RGB_DB "/usr/lib/X11/rgb.txt" -/*#define RGB_DB "/usr/openwin/lib/rgb.txt"*/ -#ifdef VMS -#define RGB_DB "PBMplus_Dir:RGB.TXT" -#endif -#endif - -/* CONFIGURE: If you want to enable writing "raw" files, set this option. -** "Raw" files are smaller, and much faster to read and write, but you -** must have a filesystem that allows all 256 ASCII characters to be read -** and written. You will no longer be able to mail P?M files without -** using uuencode or the equivalent, or running the files through pnmnoraw. -** Note that reading "raw" files works whether writing is enabled or not. -*/ -#define PBMPLUS_RAWBITS - -/* CONFIGURE: PGM can store gray values as either bytes or shorts. For most -** applications, bytes will be big enough, and the memory savings can be -** substantial. However, if you need more than 8 bits of grayscale resolution, -** then define this symbol. Unless your computer is very slow or you are short -** of memory, there is no reason why you should not set this symbol. -*/ -#define PGM_BIGGRAYS - -/* CONFIGURE: Normally, PPM handles a pixel as a struct of three grays. -** If grays are stored in bytes, that's 24 bits per color pixel; if -** grays are stored as shorts, that's 48 bits per color pixel. PPM -** can also be configured to pack the three grays into a single longword, -** 10 bits each, 30 bits per pixel. -** -** If you have configured PGM with the PGM_BIGGRAYS option, AND you don't -** need more than 10 bits for each color component, AND you care more about -** memory use than speed, then this option might be a win. Under these -** circumstances it will make some of the programs use 1.5 times less space, -** but all of the programs will run about 1.4 times slower. -** -** If you are not using PGM_BIGGRAYS, then this option is useless -- it -** doesn't save any space, but it still slows things down. -*/ -/* #define PPM_PACKCOLORS */ - -/* CONFIGURE: uncomment this to enable debugging checks. */ -/* #define DEBUG */ - -#if ( defined(SYSV) || defined(AMIGA) ) - -#include -#define random rand -#define srandom(s) srand(s) -#ifndef __SASC -#define index(s,c) strchr(s,c) -#define rindex(s,c) strrchr(s,c) -#ifndef _DCC /* Amiga DICE Compiler */ -#define bzero(dst,len) memset(dst,0,len) -#define bcopy(src,dst,len) memcpy(dst,src,len) -#define bcmp memcmp -#ifndef __cplusplus -extern void srand(); -extern int rand(); -#endif -#endif /* _DCC */ -#endif /* __SASC */ - -#else /* SYSV or AMIGA */ - -#ifndef WIN32_VC -#include -extern void srandom(); -extern long random(); -#endif - -#endif /*SYSV or AMIGA*/ - -#if (defined(MSDOS) || defined(AMIGA) ) -#include -#include -#include -#include -#define index(s,c) strchr(s,c) -#define rindex(s,c) strrchr(s,c) -#else -#ifndef __cplusplus -extern int atoi(); -extern void exit(); -extern long time(); -extern int write(); -#endif -#endif - -/* CONFIGURE: On most BSD systems, malloc() gets declared in stdlib.h, on -** system V, it gets declared in malloc.h. On some systems, malloc.h -** doesn't declare these, so we have to do it here. On other systems, -** for example HP/UX, it declares them incompatibly. And some systems, -** for example Dynix, don't have a malloc.h at all. A sad situation. -** If you have compilation problems that point here, feel free to tweak -** or remove these declarations. -*/ -#ifdef BSD -#include -#endif -#if (defined(SYSV) && !defined(VMS)) -#include -#endif -/* extern char* malloc(); */ -/* extern char* realloc(); */ -/* extern char* calloc(); */ - -/* CONFIGURE: Some systems don't have vfprintf(), which we need for the -** error-reporting routines. If you compile and get a link error about -** this routine, uncomment the first define, which gives you a vfprintf -** that uses the theoretically non-portable but fairly common routine -** _doprnt(). If you then get a link error about _doprnt, or -** message-printing doesn't look like it's working, try the second -** define instead. -*/ -/* #define NEED_VFPRINTF1 */ -/* #define NEED_VFPRINTF2 */ - -/* CONFIGURE: Some systems don't have strstr(), which some routines need. -** If you compile and get a link error about this routine, uncomment the -** define, which gives you a strstr. -*/ -/* #define NEED_STRSTR */ - -/* CONFIGURE: If you don't want a fixed path to an X11 color name file -** compiled into PBMPlus, set this option. Now RGB_DB (see Makefile) -** defines the name of an environment-variable that holds the complete -** path and name of this file. -*/ -/* #define A_RGBENV */ -#ifdef A_RGBENV -#define RGB_DB "RGBDEF" /* name of env-var */ -#endif /* A_RGBENV */ - -/* CONFIGURE: Set this option if your compiler uses strerror(errno) -** instead of sys_errlist[errno] for error messages. -*/ -/* #define A_STRERROR */ - -/* CONFIGURE: On small systems without VM it is possible that there is -** enough memory for a large array, but it is fragmented. So the usual -** malloc( all-in-one-big-chunk ) fails. With this option, if the first -** method fails, pm_allocarray() tries to allocate the array row by row. -*/ -/* #define A_FRAGARRAY */ - -/* -** Some special things for the Amiga. -*/ - -/* End of configurable definitions. */ - - -#ifdef AMIGA -#include -#define getpid(x) ((long)FindTask(NULL)) -#endif /* AMIGA */ - -/* -#undef max -#define max(a,b) ((a) > (b) ? (a) : (b)) -#undef min -#define min(a,b) ((a) < (b) ? (a) : (b)) -#undef abs -#define abs(a) ((a) >= 0 ? (a) : -(a)) -#undef odd -#define odd(n) ((n) & 1) -*/ - -/* Definitions to make PBMPLUS work with either ANSI C or C Classic. */ - -#if __STDC__ -#define ARGS(alist) alist -#else /*__STDC__*/ -#define ARGS(alist) () -/*#define const*/ -#endif /*__STDC__*/ - - -/* Initialization. */ - -EXPCL_PANDA void pm_init( int* argcP, char* argv[] ); - -/* Variable-sized arrays definitions. */ - -char** pm_allocarray ARGS(( int cols, int rows, int size )); -EXPCL_PANDA char* pm_allocrow( int cols, int size ); -void pm_freearray ARGS(( char** its, int rows )); -EXPCL_PANDA void pm_freerow( char* itrow ); - - -/* Case-insensitive keyword matcher. */ - -int pm_keymatch ARGS(( char* str, char* keyword, int minchars )); - - -/* Log base two hacks. */ - -EXPCL_PANDA int pm_maxvaltobits( int maxval ); -EXPCL_PANDA int pm_bitstomaxval( int bits ); - - -/* Error handling definitions. */ - -EXPCL_PANDA void pm_message( char*, ... ); -EXPCL_PANDA void pm_error( char*, ... ); /* doesn't return */ -void pm_perror ARGS(( char* reason )); /* doesn't return */ -void pm_usage ARGS(( char* usage )); /* doesn't return */ - - -/* File open/close that handles "-" as stdin and checks errors. */ - -EXPCL_PANDA FILE* pm_openr( char* name ); -EXPCL_PANDA FILE* pm_openw( char* name ); -EXPCL_PANDA void pm_close( FILE* f ); - - -/* Endian I/O. */ - -EXPCL_PANDA int pm_readbigshort( FILE* in, short* sP ); -EXPCL_PANDA int pm_writebigshort( FILE* out, short s ); -EXPCL_PANDA int pm_readbiglong( FILE* in, long* lP ); -EXPCL_PANDA int pm_writebiglong( FILE* out, long l ); -EXPCL_PANDA int pm_readlittleshort( FILE* in, short* sP ); -EXPCL_PANDA int pm_writelittleshort( FILE* out, short s ); -EXPCL_PANDA int pm_readlittlelong( FILE* in, long* lP ); -EXPCL_PANDA int pm_writelittlelong( FILE* out, long l ); - - -/* Compatibility stuff */ - -#ifdef NEED_STRSTR -char *strstr ARGS((char *s1, char *s2)); -#endif - -#if defined(NEED_VFPRINTF1) || defined(NEED_VFPRINTF2) -int vfprintf ARGS(( FILE* stream, char* format, va_list args )); -#endif /*NEED_VFPRINTF*/ - - -#endif /*_PBMPLUS_H_*/ diff --git a/panda/src/pnm/pgm.h b/panda/src/pnm/pgm.h deleted file mode 100644 index 378c3226ff..0000000000 --- a/panda/src/pnm/pgm.h +++ /dev/null @@ -1,57 +0,0 @@ -/* pgm.h - header file for libpgm portable graymap library -*/ - -#ifndef _PGM_H_ -#define _PGM_H_ - -#include - -#include "pbm.h" - -#ifdef PGM_BIGGRAYS -typedef unsigned short gray; -#define PGM_MAXMAXVAL 65535 -#else /*PGM_BIGGRAYS*/ -typedef unsigned char gray; -#define PGM_MAXMAXVAL 255 -#endif /*PGM_BIGGRAYS*/ - - -/* Magic constants. */ - -#define PGM_MAGIC1 'P' -#define PGM_MAGIC2 '2' -#define RPGM_MAGIC2 '5' -#define PGM_FORMAT (PGM_MAGIC1 * 256 + PGM_MAGIC2) -#define RPGM_FORMAT (PGM_MAGIC1 * 256 + RPGM_MAGIC2) -#define PGM_TYPE PGM_FORMAT - - -/* Macro for turning a format number into a type number. */ - -#define PGM_FORMAT_TYPE(f) ((f) == PGM_FORMAT || (f) == RPGM_FORMAT ? PGM_TYPE : PBM_FORMAT_TYPE(f)) - - -/* Declarations of routines. */ - -void pgm_init ARGS(( int* argcP, char* argv[] )); - -#define pgm_allocarray( cols, rows ) ((gray**) pm_allocarray( cols, rows, sizeof(gray) )) -#define pgm_allocrow( cols ) ((gray*) pm_allocrow( cols, sizeof(gray) )) -#define pgm_freearray( grays, rows ) pm_freearray( (char**) grays, rows ) -#define pgm_freerow( grayrow ) pm_freerow( (char*) grayrow ) - -gray** pgm_readpgm ARGS(( FILE* file, int* colsP, int* rowsP, gray* maxvalP )); -void pgm_readpgminit ARGS(( FILE* file, int* colsP, int* rowsP, gray* maxvalP, int* formatP )); -void pgm_readpgmrow ARGS(( FILE* file, gray* grayrow, int cols, gray maxval, int format )); - -void pgm_writepgm ARGS(( FILE* file, gray** grays, int cols, int rows, gray maxval, int forceplain )); -void pgm_writepgminit ARGS(( FILE* file, int cols, int rows, gray maxval, int forceplain )); -void pgm_writepgmrow ARGS(( FILE* file, gray* grayrow, int cols, gray maxval, int forceplain )); - -extern gray pgm_pbmmaxval; -/* This is the maxval used when a PGM program reads a PBM file. Normally -** it is 1; however, for some programs, a larger value gives better results -*/ - -#endif /*_PGM_H_*/ diff --git a/panda/src/pnm/pnm.h b/panda/src/pnm/pnm.h deleted file mode 100644 index 4e3d981743..0000000000 --- a/panda/src/pnm/pnm.h +++ /dev/null @@ -1,48 +0,0 @@ -/* pnm.h - header file for libpnm portable anymap library -*/ - -#ifndef _PNM_H_ -#define _PNM_H_ - -#include - -#include "ppm.h" -typedef pixel xel; -typedef pixval xelval; -#define PNM_MAXMAXVAL PPM_MAXMAXVAL -#define PNM_GET1(x) PPM_GETB(x) -#define PNM_ASSIGN1(x,v) PPM_ASSIGN(x,0,0,v) -#define PNM_EQUAL(x,y) PPM_EQUAL(x,y) -#define PNM_FORMAT_TYPE(f) PPM_FORMAT_TYPE(f) - -/* Declarations of routines. */ - -void pnm_init ARGS(( int* argcP, char* argv[] )); - -#define pnm_allocarray( cols, rows ) ((xel**) pm_allocarray( cols, rows, sizeof(xel) )) -#define pnm_allocrow( cols ) ((xel*) pm_allocrow( cols, sizeof(xel) )) -#define pnm_freearray( xels, rows ) pm_freearray( (char**) xels, rows ) -#define pnm_freerow( xelrow ) pm_freerow( (char*) xelrow ) - -xel** pnm_readpnm ARGS(( FILE* file, int* colsP, int* rowsP, xelval* maxvalP, int* formatP )); -EXPCL_PANDA void pnm_readpnminit( FILE* file, int* colsP, int* rowsP, xelval* maxvalP, int* formatP ); -EXPCL_PANDA void pnm_readpnmrow( FILE* file, xel* xelrow, int cols, xelval maxval, int format ); - -void pnm_writepnm ARGS(( FILE* file, xel** xels, int cols, int rows, xelval maxval, int format, int forceplain )); -EXPCL_PANDA void pnm_writepnminit( FILE* file, int cols, int rows, xelval maxval, int format, int forceplain ); -EXPCL_PANDA void pnm_writepnmrow( FILE* file, xel* xelrow, int cols, xelval maxval, int format, int forceplain ); - -xel pnm_backgroundxel ARGS(( xel** xels, int cols, int rows, xelval maxval, int format )); -xel pnm_backgroundxelrow ARGS(( xel* xelrow, int cols, xelval maxval, int format )); -xel pnm_whitexel ARGS(( xelval maxval, int format )); -xel pnm_blackxel ARGS(( xelval maxval, int format )); -void pnm_invertxel ARGS(( xel* x, xelval maxval, int format )); -void pnm_promoteformat ARGS(( xel** xels, int cols, int rows, xelval maxval, int format, xelval newmaxval, int newformat )); -void pnm_promoteformatrow ARGS(( xel* xelrow, int cols, xelval maxval, int format, xelval newmaxval, int newformat )); - -extern EXPCL_PANDA xelval pnm_pbmmaxval; -/* This is the maxval used when a PNM program reads a PBM file. Normally -** it is 1; however, for some programs, a larger value gives better results -*/ - -#endif /*_PNM_H_*/ diff --git a/panda/src/pnm/ppm.h b/panda/src/pnm/ppm.h deleted file mode 100644 index 9a0bce1422..0000000000 --- a/panda/src/pnm/ppm.h +++ /dev/null @@ -1,107 +0,0 @@ -/* ppm.h - header file for libppm portable pixmap library -*/ - -#ifndef _PPM_H_ -#define _PPM_H_ - -#include - -#include "pgm.h" - -typedef gray pixval; - -#ifdef PPM_PACKCOLORS - -#define PPM_MAXMAXVAL 1023 -typedef unsigned long pixel; -#define PPM_GETR(p) (((p) & 0x3ff00000) >> 20) -#define PPM_GETG(p) (((p) & 0xffc00) >> 10) -#define PPM_GETB(p) ((p) & 0x3ff) - -/************* added definitions *****************/ -#define PPM_PUTR(p, red) ((p) |= (((red) & 0x3ff) << 20)) -#define PPM_PUTG(p, grn) ((p) |= (((grn) & 0x3ff) << 10)) -#define PPM_PUTB(p, blu) ((p) |= ( (blu) & 0x3ff)) -/**************************************************/ - -#define PPM_ASSIGN(p,red,grn,blu) (p) = ((pixel) (red) << 20) | ((pixel) (grn) << 10) | (pixel) (blu) -#define PPM_EQUAL(p,q) ((p) == (q)) - -#else /*PPM_PACKCOLORS*/ - -#define PPM_MAXMAXVAL PGM_MAXMAXVAL -typedef struct - { - pixval r, g, b; - } pixel; -#define PPM_GETR(p) ((p).r) -#define PPM_GETG(p) ((p).g) -#define PPM_GETB(p) ((p).b) - -/************* added definitions *****************/ -#define PPM_PUTR(p,red) ((p).r = (red)) -#define PPM_PUTG(p,grn) ((p).g = (grn)) -#define PPM_PUTB(p,blu) ((p).b = (blu)) -/**************************************************/ - -#define PPM_ASSIGN(p,red,grn,blu) do { (p).r = (red); (p).g = (grn); (p).b = (blu); } while ( 0 ) -#define PPM_EQUAL(p,q) ( (p).r == (q).r && (p).g == (q).g && (p).b == (q).b ) - -#endif /*PPM_PACKCOLORS*/ - - -/* Magic constants. */ - -#define PPM_MAGIC1 'P' -#define PPM_MAGIC2 '3' -#define RPPM_MAGIC2 '6' -#define PPM_FORMAT (PPM_MAGIC1 * 256 + PPM_MAGIC2) -#define RPPM_FORMAT (PPM_MAGIC1 * 256 + RPPM_MAGIC2) -#define PPM_TYPE PPM_FORMAT - - -/* Macro for turning a format number into a type number. */ - -#define PPM_FORMAT_TYPE(f) ((f) == PPM_FORMAT || (f) == RPPM_FORMAT ? PPM_TYPE : PGM_FORMAT_TYPE(f)) - - -/* Declarations of routines. */ - -void ppm_init ARGS(( int* argcP, char* argv[] )); - -#define ppm_allocarray( cols, rows ) ((pixel**) pm_allocarray( cols, rows, sizeof(pixel) )) -#define ppm_allocrow( cols ) ((pixel*) pm_allocrow( cols, sizeof(pixel) )) -#define ppm_freearray( pixels, rows ) pm_freearray( (char**) pixels, rows ) -#define ppm_freerow( pixelrow ) pm_freerow( (char*) pixelrow ) - -pixel** ppm_readppm ARGS(( FILE* file, int* colsP, int* rowsP, pixval* maxvalP )); -void ppm_readppminit ARGS(( FILE* file, int* colsP, int* rowsP, pixval* maxvalP, int* formatP )); -void ppm_readppmrow ARGS(( FILE* file, pixel* pixelrow, int cols, pixval maxval, int format )); - -void ppm_writeppm ARGS(( FILE* file, pixel** pixels, int cols, int rows, pixval maxval, int forceplain )); -void ppm_writeppminit ARGS(( FILE* file, int cols, int rows, pixval maxval, int forceplain )); -void ppm_writeppmrow ARGS(( FILE* file, pixel* pixelrow, int cols, pixval maxval, int forceplain )); - -pixel ppm_parsecolor ARGS(( char* colorname, pixval maxval )); -char* ppm_colorname ARGS(( pixel* colorP, pixval maxval, int hexok )); - -extern pixval ppm_pbmmaxval; -/* This is the maxval used when a PPM program reads a PBM file. Normally -** it is 1; however, for some programs, a larger value gives better results -*/ - - -/* Color scaling macro -- to make writing ppmtowhatever easier. */ - -#define PPM_DEPTH(newp,p,oldmaxval,newmaxval) \ - PPM_ASSIGN( (newp), \ - ( (int) PPM_GETR(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval), \ - ( (int) PPM_GETG(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval), \ - ( (int) PPM_GETB(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval) ) - - -/* Luminance macro. */ - -#define PPM_LUMIN(p) ( 0.299 * PPM_GETR(p) + 0.587 * PPM_GETG(p) + 0.114 * PPM_GETB(p) ) - -#endif /*_PPM_H_*/ diff --git a/panda/src/pnm/ppmdraw.h b/panda/src/pnm/ppmdraw.h deleted file mode 100644 index 14eea55fe9..0000000000 --- a/panda/src/pnm/ppmdraw.h +++ /dev/null @@ -1,103 +0,0 @@ -/* ppmdraw.h - header file for simple drawing routines in libppm -** -** Simple, yes, and also fairly slow if the truth be told; but also very -** flexible and powerful. -** -** The two basic concepts are the drawproc and clientdata. All the drawing -** routines take a drawproc that does the actual drawing. A drawproc draws -** a single point, and it looks like this: -*/ -void ppmd_point_drawproc ARGS(( pixel** pixels, int cols, int rows, pixval maxval, int x, int y, char* clientdata )); -/* -** So, you call a drawing routine, e.g. ppmd_line(), and pass it a drawproc; -** it calls the drawproc for each point it wants to draw. Why so complicated? -** Because you can define your own drawprocs to do more interesting things than -** simply draw the point. For example, you could make one that calls back into -** another drawing routine, say ppmd_circle() to draw a circle at each point -** of a line. -** -** Slow? Well sure, we're talking results here, not realtime. You can do -** tricks with this arrangement that you couldn't even think of before. -** Still, to speed things up for the 90% case you can use this: -*/ -#if __STDC__ -#define PPMD_NULLDRAWPROC (void (*)(pixel**, int, int, pixval, int, int, char*)) 0 -#else /*__STDC__*/ -#define PPMD_NULLDRAWPROC (void (*)()) 0 -#endif /*__STDC__*/ -/* -** Just like ppmd_point_drawproc() it simply draws the point, but it's done -** inline, and clipping is assumed to be handled at a higher level. -** -** Now, what about clientdata. Well, it's an arbitrary pointer, and can -** mean something different to each different drawproc. For the above two -** drawprocs, clientdata should be a pointer to a pixel holding the color -** to be drawn. Other drawprocs can use it to point to something else, -** e.g. some structure to be modified, or they can ignore it. -*/ - - -/* Outline drawing routines. Lines, splines, circles, etc. */ - -int ppmd_setlinetype ARGS(( int type )); -#define PPMD_LINETYPE_NORMAL 0 -#define PPMD_LINETYPE_NODIAGS 1 -/* If you set NODIAGS, all pixels drawn by ppmd_line() will be 4-connected -** instead of 8-connected; in other words, no diagonals. This is useful -** for some applications, for example when you draw many parallel lines -** and you want them to fit together without gaps. -*/ - -int ppmd_setlineclip ARGS(( int clip )); -#define ppmd_setlineclipping(x) ppmd_setlineclip(x) -/* Normally, ppmd_line() clips to the edges of the pixmap. You can use this -** routine to disable the clipping, for example if you are using a drawproc -** that wants to do its own clipping. -*/ - -void ppmd_line ARGS(( pixel** pixels, int cols, int rows, pixval maxval, int x0, int y0, int x1, int y1, void (*drawprocP)(pixel**, int, int, pixval, int, int, char*), char* clientdata )); -/* Draws a line from (x0, y0) to (x1, y1). -*/ - -void ppmd_spline3 ARGS(( pixel** pixels, int cols, int rows, pixval maxval, int x0, int y0, int x1, int y1, int x2, int y2, void (*drawprocP)(pixel**, int, int, pixval, int, int, char*), char* clientdata )); -/* Draws a three-point spline from (x0, y0) to (x2, y2), with (x1, y1) as -** the control point. All drawing is done via ppmd_line(), so the routines -** that control it control ppmd_spline3() as well. -*/ - -void ppmd_polyspline ARGS(( pixel** pixels, int cols, int rows, pixval maxval, int x0, int y0, int nc, int* xc, int* yc, int x1, int y1, void (*drawprocP)(pixel**, int, int, pixval, int, int, char*), char* clientdata )); -/* Draws a bunch of splines end to end. (x0, y0) and (x1, y1) are the initial -** and final points, and the xc and yc are the intermediate control points. -** nc is the number of these control points. -*/ - -void ppmd_circle ARGS(( pixel** pixels, int cols, int rows, pixval maxval, int cx, int cy, int radius, void (*drawprocP)(pixel**, int, int, pixval, int, int, char*), char* clientdata )); -/* Draws a circle centered at (cx, cy) with the specified radius. -*/ - - -/* Simple filling routines. Ok, so there's only one. */ - -void ppmd_filledrectangle ARGS(( pixel** pixels, int cols, int rows, pixval maxval, int x, int y, int width, int height, void (*drawprocP)(pixel**, int, int, pixval, int, int, char*), char* clientdata )); -/* Fills in the rectangle [x, y, width, height]. -*/ - - -/* Arbitrary filling routines. With these you can fill any outline that -** you can draw with the outline routines. -*/ - -char* ppmd_fill_init ARGS(( void )); -/* Returns a blank fillhandle. -*/ - -void ppmd_fill_drawproc ARGS(( pixel** pixels, int cols, int rows, pixval maxval, int x, int y, char* clientdata )); -/* Use this drawproc to trace the outline you want filled. Be sure to use -** the fillhandle as the clientdata. -*/ - -void ppmd_fill ARGS(( pixel** pixels, int cols, int rows, pixval maxval, char* fillhandle, void (*drawprocP)(pixel**, int, int, pixval, int, int, char*), char* clientdata )); -/* Once you've traced the outline, give the fillhandle to this routine to -** do the actual drawing. As usual, it takes a drawproc and clientdata; -** you could define drawprocs to do stipple fills and such. -*/ diff --git a/panda/src/pnm/rast.h b/panda/src/pnm/rast.h deleted file mode 100644 index a4f99d681a..0000000000 --- a/panda/src/pnm/rast.h +++ /dev/null @@ -1,111 +0,0 @@ -/* rast.h - header file for Sun raster files -** -** The format of a Sun raster file is as follows. First, a struct -** rasterfile. Note the 32-bit magic number at the beginning; this -** identifies the file type and lets you figure out whether you need -** to do little-endian / big-endian byte-swapping or not. (The PBMPLUS -** implementation does not do byte-swapping; instead, it reads all -** multi-byte values a byte at a time.) -** -** After the struct is an optional colormap. If ras_maptype is RMT_NONE, -** no map is present; if it's RMT_EQUAL_RGB then the map consists of -** three unsigned-char arrays ras_maplength long, one each for r g and b. -** I don't know what RMT_RAW means. Black and white bitmaps are stored -** as ras_maptype == RMT_NONE and ras_depth == 1, with the bits stored -** eight to a byte MSB first. -** -** Finally comes the image data. If ras_type is RT_OLD or RT_STANDARD, -** the data is just plain old uncompressed bytes, padded out to a multiple -** of 16 bits in each row. If ras_type is RT_BYTE_ENCODED, a run-length -** compression scheme is used: an escape-byte of 128 indicates a run; -** the next byte is a count, and the one after that is the byte to be -** replicated. The one exception to this is if the count is 1; then -** there is no third byte in the packet, it means to put a single 128 -** in the data stream. -*/ - -#ifndef _RAST_H_ -#define _RAST_H_ - -#define PIX_ERR -1 - -struct rasterfile { - long ras_magic; -#define RAS_MAGIC 0x59a66a95 - long ras_width; - long ras_height; - long ras_depth; - long ras_length; - long ras_type; -#define RT_OLD 0 /* Raw pixrect image in 68000 byte order */ -#define RT_STANDARD 1 /* Raw pixrect image in 68000 byte order */ -#define RT_BYTE_ENCODED 2 /* Run-length compression of bytes */ -#define RT_FORMAT_RGB 3 /* XRGB or RGB instead of XBGR or BGR */ -#define RT_FORMAT_TIFF 4 /* tiff <-> standard rasterfile */ -#define RT_FORMAT_IFF 5 /* iff (TAAC format) <-> standard rasterfile */ -#define RT_EXPERIMENTAL 0xffff /* Reserved for testing */ - long ras_maptype; -#define RMT_NONE 0 -#define RMT_EQUAL_RGB 1 -#define RMT_RAW 2 - long ras_maplength; - }; - -struct pixrectops { - int (*pro_rop)(); - int (*pro_stencil)(); - int (*pro_batchrop)(); - int (*pro_nop)(); - int (*pro_destroy)(); - int (*pro_get)(); - int (*pro_put)(); - int (*pro_vector)(); - struct pixrect* (*pro_region)(); - int (*pro_putcolormap)(); - int (*pro_getcolormap)(); - int (*pro_putattributes)(); - int (*pro_getattributes)(); - }; - -struct pr_size { - int x, y; - }; -struct pr_pos { - int x, y; - }; - -struct pixrect { - struct pixrectops* pr_ops; - struct pr_size pr_size; - int pr_depth; - struct mpr_data* pr_data; /* work-alike only handles memory pixrects */ - }; - -struct mpr_data { - int md_linebytes; - unsigned char* md_image; /* note, byte not short -- avoid pr_flip() */ - struct pr_pos md_offset; - short md_primary; - short md_flags; - }; - -typedef struct { - int type; - int length; - unsigned char* map[3]; - } colormap_t; - -/* And the routine definitions. */ - -struct pixrect* mem_create ARGS(( int w, int h, int depth )); -void mem_free ARGS(( struct pixrect* p )); - -int pr_dump ARGS(( struct pixrect* p, FILE* out, colormap_t* colormap, int type, int copy_flag )); - -int pr_load_header ARGS(( FILE* in, struct rasterfile* hP )); - -int pr_load_colormap ARGS(( FILE* in, struct rasterfile* hP, colormap_t* colormap )); - -struct pixrect* pr_load_image ARGS(( FILE* in, struct rasterfile* hP, colormap_t* colormap )); - -#endif /*_RAST_H_*/ diff --git a/panda/src/pnm/version.h b/panda/src/pnm/version.h deleted file mode 100644 index 8a4ff05eab..0000000000 --- a/panda/src/pnm/version.h +++ /dev/null @@ -1,4 +0,0 @@ -/* version.h - define the current version of the package -*/ - -#define PBMPLUS_VERSION "Netpbm 1 March 1994" diff --git a/panda/src/pnmimage/Sources.pp b/panda/src/pnmimage/Sources.pp index 16b431c13c..a75b0e9990 100644 --- a/panda/src/pnmimage/Sources.pp +++ b/panda/src/pnmimage/Sources.pp @@ -4,19 +4,25 @@ #begin lib_target #define TARGET pnmimage #define LOCAL_LIBS \ - pnm linmath putil express + linmath putil express #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx #define SOURCES \ - config_pnmimage.h pnmFileType.h pnmFileTypeRegistry.h pnmImage.I \ + config_pnmimage.h \ + pnmbitio.h \ + pnmFileType.h pnmFileTypeRegistry.h pnmImage.I \ pnmImage.h pnmImageHeader.I pnmImageHeader.h pnmReader.I \ - pnmReader.h pnmWriter.I pnmWriter.h + pnmReader.h pnmWriter.I pnmWriter.h pnmimage_base.h \ + ppmcmap.h #define INCLUDED_SOURCES \ - config_pnmimage.cxx pnm-image-filter.cxx pnmFileType.cxx \ + config_pnmimage.cxx \ + pnmbitio.cxx \ + pnm-image-filter.cxx pnmFileType.cxx \ pnmFileTypeRegistry.cxx pnmImage.cxx pnmImageHeader.cxx \ - pnmReader.cxx pnmWriter.cxx + pnmReader.cxx pnmWriter.cxx pnmimage_base.cxx \ + ppmcmap.cxx #define INSTALL_HEADERS \ config_pnmimage.h pnmFileType.h pnmFileTypeRegistry.h pnmImage.I \ diff --git a/panda/src/pnmimage/pnmFileType.cxx b/panda/src/pnmimage/pnmFileType.cxx index 9fd7eed518..a21f6d80bb 100644 --- a/panda/src/pnmimage/pnmFileType.cxx +++ b/panda/src/pnmimage/pnmFileType.cxx @@ -144,6 +144,9 @@ init_pnm() { if (!_did_init_pnm) { _did_init_pnm = true; + // No reason to do anything here now. + /* + // Make an argc/argv style copy of the ExecutionEnvironment's // args. We do this because pm_init() might attempt to change // this (for instance, to remove arguments it finds). @@ -164,6 +167,8 @@ init_pnm() { // library might keep pointers to it. But this is a one-time // leak. delete[] argv; + + */ } } diff --git a/panda/src/pnmimage/pnmImage.cxx b/panda/src/pnmimage/pnmImage.cxx index 2671c1a150..4aa57b8eff 100644 --- a/panda/src/pnmimage/pnmImage.cxx +++ b/panda/src/pnmimage/pnmImage.cxx @@ -21,16 +21,6 @@ #include "pnmWriter.h" #include "config_pnmimage.h" -extern "C" { -#include "../pnm/pnm.h" -#include "../pnm/ppm.h" -#include "../pnm/pgm.h" -#include "../pnm/pbm.h" -#include "../pnm/libppm.h" -#include "../pnm/libpgm.h" -#include "../pnm/libpbm.h" -} - //////////////////////////////////////////////////////////////////// // Function: PNMImage::clear // Access: Public diff --git a/panda/src/pnmimage/pnmImage.h b/panda/src/pnmimage/pnmImage.h index 31e5d1197c..cdc23f9b4d 100644 --- a/panda/src/pnmimage/pnmImage.h +++ b/panda/src/pnmimage/pnmImage.h @@ -19,11 +19,11 @@ #ifndef PNMIMAGE_H #define PNMIMAGE_H -#include +#include "pandabase.h" #include "pnmImageHeader.h" -#include +#include "luse.h" class PNMReader; class PNMWriter; @@ -31,7 +31,17 @@ class PNMFileType; //////////////////////////////////////////////////////////////////// // Class : PNMImage -// Description : Conceptually, a PNMImage is a two-dimensional array +// Description : The name of this class derives from the fact that we +// originally implemented it as a layer on top of the +// "pnm library", based on netpbm, which was built to +// implement pbm, pgm, and pbm files, and is the +// underlying support of a number of public-domain image +// file converters. Nowadays we are no longer derived +// directly from the pnm library, mainly to allow +// support of C++ iostreams instead of the C stdio FILE +// interface. +// +// Conceptually, a PNMImage is a two-dimensional array // of xels, which are the PNM-defined generic pixel // type. Each xel may have a red, green, and blue // component, or (if the image is grayscale) a gray @@ -43,11 +53,8 @@ class PNMFileType; // numbered from top to bottom, left to right, beginning // at zero. // -// Files can be specified by filename, or by a -// stdio-style FILE pointer. Unfortunately, C++ streams -// cannot be supported, because of the underlying C code -// in libpnm. The filename "-" refers to stdin or -// stdout. +// Files can be specified by filename, or by an iostream +// pointer. The filename "-" refers to stdin or stdout. //////////////////////////////////////////////////////////////////// class EXPCL_PANDA PNMImage : public PNMImageHeader { public: diff --git a/panda/src/pnmimage/pnmImageHeader.cxx b/panda/src/pnmimage/pnmImageHeader.cxx index 51dea5e5ea..00e9eaa891 100644 --- a/panda/src/pnmimage/pnmImageHeader.cxx +++ b/panda/src/pnmimage/pnmImageHeader.cxx @@ -88,7 +88,7 @@ make_reader(const Filename &filename, PNMFileType *type) const { } owns_file = true; string os_specific = actual_name.to_os_specific(); - file = pm_openr((char *)os_specific.c_str()); + file = fopen((char *)os_specific.c_str(), "rb"); } if (file == (FILE *)NULL) { @@ -143,7 +143,7 @@ make_reader(FILE *file, bool owns_file, const Filename &filename, << "Image file appears to be empty.\n"; } if (owns_file) { - pm_close(file); + fclose(file); } return NULL; } @@ -200,14 +200,14 @@ make_reader(FILE *file, bool owns_file, const Filename &filename, write_types(pnmimage_cat.error(false), 2); } if (owns_file) { - pm_close(file); + fclose(file); } return NULL; } PNMReader *reader = type->make_reader(file, owns_file, magic_number); if (reader == NULL && owns_file) { - pm_close(file); + fclose(file); } if (!reader->is_valid()) { @@ -253,7 +253,7 @@ make_writer(const Filename &filename, PNMFileType *type) const { } else { owns_file = true; string os_specific = actual_name.to_os_specific(); - file = pm_openw((char *)os_specific.c_str()); + file = fopen((char *)os_specific.c_str(), "wb"); } if (file == (FILE *)NULL) { @@ -328,14 +328,14 @@ make_writer(FILE *file, bool owns_file, const Filename &filename, << "Cannot determine type of image file " << filename << ".\n"; } if (owns_file) { - pm_close(file); + fclose(file); } return NULL; } PNMWriter *writer = type->make_writer(file, owns_file); if (writer == NULL && owns_file) { - pm_close(file); + fclose(file); } return writer; diff --git a/panda/src/pnmimage/pnmImageHeader.h b/panda/src/pnmimage/pnmImageHeader.h index e323b6e11a..cd67fe017c 100644 --- a/panda/src/pnmimage/pnmImageHeader.h +++ b/panda/src/pnmimage/pnmImageHeader.h @@ -19,12 +19,12 @@ #ifndef PNMIMAGEHEADER_H #define PNMIMAGEHEADER_H -#include +#include "pandabase.h" #include "pnmimage_base.h" -#include -#include +#include "typedObject.h" +#include "filename.h" class PNMFileType; class PNMReader; diff --git a/panda/src/pnmimage/pnmReader.cxx b/panda/src/pnmimage/pnmReader.cxx index a5b46e13a9..aa5bc2fd6d 100644 --- a/panda/src/pnmimage/pnmReader.cxx +++ b/panda/src/pnmimage/pnmReader.cxx @@ -26,7 +26,7 @@ PNMReader:: ~PNMReader() { if (_owns_file) { - pm_close(_file); + fclose(_file); } } diff --git a/panda/src/pnmimage/pnmWriter.cxx b/panda/src/pnmimage/pnmWriter.cxx index 46b792be4f..e550737aaa 100644 --- a/panda/src/pnmimage/pnmWriter.cxx +++ b/panda/src/pnmimage/pnmWriter.cxx @@ -26,7 +26,7 @@ PNMWriter:: ~PNMWriter() { if (_owns_file) { - pm_close(_file); + fclose(_file); } } diff --git a/panda/src/pnm/bitio.c b/panda/src/pnmimage/pnmbitio.cxx similarity index 99% rename from panda/src/pnm/bitio.c rename to panda/src/pnmimage/pnmbitio.cxx index 40dc97f16f..fe381fa0f6 100644 --- a/panda/src/pnm/bitio.c +++ b/panda/src/pnmimage/pnmbitio.cxx @@ -13,7 +13,7 @@ * without express or implied warranty. */ -#include "bitio.h" +#include "pnmbitio.h" #include struct bitstream { diff --git a/panda/src/pnm/bitio.h b/panda/src/pnmimage/pnmbitio.h similarity index 97% rename from panda/src/pnm/bitio.h rename to panda/src/pnmimage/pnmbitio.h index 2a2a713027..7f6fab0441 100644 --- a/panda/src/pnm/bitio.h +++ b/panda/src/pnmimage/pnmbitio.h @@ -16,9 +16,8 @@ #ifndef _BITIO_H_ #define _BITIO_H_ -#include - -#include "pbmplus.h" +#include "pandabase.h" +#include "pnmimage_base.h" typedef struct bitstream *BITSTREAM; diff --git a/panda/src/pnmimage/pnmimage_base.cxx b/panda/src/pnmimage/pnmimage_base.cxx new file mode 100644 index 0000000000..1ff9f3a710 --- /dev/null +++ b/panda/src/pnmimage/pnmimage_base.cxx @@ -0,0 +1,216 @@ +// Filename: pnmimage_base.cxx +// Created by: drose (04Aug02) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://www.panda3d.org/license.txt . +// +// To contact the maintainers of this program write to +// panda3d@yahoogroups.com . +// +//////////////////////////////////////////////////////////////////// + +#include "pnmimage_base.h" + +#include +#include + +//////////////////////////////////////////////////////////////////// +// Function: pm_message +// Description: Outputs the given printf-style message to the user +// and returns. +//////////////////////////////////////////////////////////////////// +void +pm_message(const char *format, ...) { + va_list ap; + va_start(ap, format); + + static const size_t buffer_size = 1024; + char buffer[buffer_size]; + vsnprintf(buffer, buffer_size, format, ap); + + pnmimage_cat.info() << buffer << "\n"; + + va_end(ap); +} + +//////////////////////////////////////////////////////////////////// +// Function: pm_error +// Description: Outputs the given printf-style message to the user +// and terminates messily. Minimize use of this +// function. +//////////////////////////////////////////////////////////////////// +void +pm_error(const char *format, ...) { + va_list ap; + va_start(ap, format); + + static const size_t buffer_size = 1024; + char buffer[buffer_size]; + vsnprintf(buffer, buffer_size, format, ap); + + pnmimage_cat.error() << buffer << "\n"; + + va_end(ap); + + // Now we're supposed to exit. Inconvenient if we were running + // Panda interactively, but that's the way it is. + exit(1); +} + +//////////////////////////////////////////////////////////////////// +// Function: pm_maxvaltobits +// Description: Returns the number of bits sufficient to hold the +// indicated maxval value. +//////////////////////////////////////////////////////////////////// +int +pm_maxvaltobits(int maxval) { + int bits = 1; + while (maxval > pm_bitstomaxval(bits)) { + bits++; + nassertr(bits != 0, 16); + } + return bits; +} + +//////////////////////////////////////////////////////////////////// +// Function: pm_bitstomaxval +// Description: Returns the highest maxval that can be represented in +// the indicated number of bits. +//////////////////////////////////////////////////////////////////// +int +pm_bitstomaxval(int bits) { + return ( 1 << bits ) - 1; +} + +//////////////////////////////////////////////////////////////////// +// Function: pm_allocrow +// Description: Allocates a row of cols * size bytes. +//////////////////////////////////////////////////////////////////// +char * +pm_allocrow(int cols, int size) { + return new char[cols * size]; +} + +//////////////////////////////////////////////////////////////////// +// Function: pm_freerow +// Description: Frees the row previously allocated withm pm_allocrow(). +//////////////////////////////////////////////////////////////////// +void +pm_freerow(char *itrow) { + delete[] itrow; +} + + +/* Endian I/O. +*/ + +int +pm_readbigshort(FILE* in, short* sP) + { + int c; + + if ( (c = getc( in )) == EOF ) + return -1; + *sP = ( c & 0xff ) << 8; + if ( (c = getc( in )) == EOF ) + return -1; + *sP |= c & 0xff; + return 0; + } + +int +pm_writebigshort( FILE* out, short s ) + { + (void) putc( ( s >> 8 ) & 0xff, out ); + (void) putc( s & 0xff, out ); + return 0; + } + +int +pm_readbiglong(FILE* in, long* lP) + { + int c; + + if ( (c = getc( in )) == EOF ) + return -1; + *lP = ( c & 0xff ) << 24; + if ( (c = getc( in )) == EOF ) + return -1; + *lP |= ( c & 0xff ) << 16; + if ( (c = getc( in )) == EOF ) + return -1; + *lP |= ( c & 0xff ) << 8; + if ( (c = getc( in )) == EOF ) + return -1; + *lP |= c & 0xff; + return 0; + } + +int +pm_writebiglong(FILE* out, long l) + { + (void) putc( ( l >> 24 ) & 0xff, out ); + (void) putc( ( l >> 16 ) & 0xff, out ); + (void) putc( ( l >> 8 ) & 0xff, out ); + (void) putc( l & 0xff, out ); + return 0; + } + +int +pm_readlittleshort(FILE* in, short* sP) + { + int c; + + if ( (c = getc( in )) == EOF ) + return -1; + *sP = c & 0xff; + if ( (c = getc( in )) == EOF ) + return -1; + *sP |= ( c & 0xff ) << 8; + return 0; + } + +int +pm_writelittleshort( FILE* out, short s ) + { + (void) putc( s & 0xff, out ); + (void) putc( ( s >> 8 ) & 0xff, out ); + return 0; + } + +int +pm_readlittlelong(FILE* in, long* lP) + { + int c; + + if ( (c = getc( in )) == EOF ) + return -1; + *lP = c & 0xff; + if ( (c = getc( in )) == EOF ) + return -1; + *lP |= ( c & 0xff ) << 8; + if ( (c = getc( in )) == EOF ) + return -1; + *lP |= ( c & 0xff ) << 16; + if ( (c = getc( in )) == EOF ) + return -1; + *lP |= ( c & 0xff ) << 24; + return 0; + } + +int +pm_writelittlelong(FILE* out, long l) + { + (void) putc( l & 0xff, out ); + (void) putc( ( l >> 8 ) & 0xff, out ); + (void) putc( ( l >> 16 ) & 0xff, out ); + (void) putc( ( l >> 24 ) & 0xff, out ); + return 0; + } diff --git a/panda/src/pnmimage/pnmimage_base.h b/panda/src/pnmimage/pnmimage_base.h index 754717a603..8bdbd42a70 100644 --- a/panda/src/pnmimage/pnmimage_base.h +++ b/panda/src/pnmimage/pnmimage_base.h @@ -22,31 +22,78 @@ // This header file make a few typedefs and other definitions // essential to everything in the PNMImage package. -#include +#include "pandabase.h" -#include #include +#include -// These include files are kludges against slightly incorrect headers given -// in pbm*.h. -#include -#include -#include +// Since we no longer include pnm.h directly, we have to provide our +// own definitions for xel and xelval. -extern "C" { - #include - #include - #include - #include - #include -} +// For now, we have PGM_BIGGRAYS defined, which gives us 16-bit +// channels. Undefine this if you have memory problems and need to +// use 8-bit channels instead. +#define PGM_BIGGRAYS + +#ifdef PGM_BIGGRAYS +typedef unsigned short gray; +#define PGM_MAXMAXVAL 65535 +#else // PGM_BIGGRAYS +typedef unsigned char gray; +#define PGM_MAXMAXVAL 255 +#endif // PGM_BIGGRAYS + +#define PNM_MAXMAXVAL PGM_MAXMAXVAL + +struct pixel { + gray r, g, b; +}; + +typedef gray pixval; +typedef pixel xel; +typedef gray xelval; + +// These macros are borrowed from ppm.h. + +#define PPM_GETR(p) ((p).r) +#define PPM_GETG(p) ((p).g) +#define PPM_GETB(p) ((p).b) + +#define PPM_PUTR(p,red) ((p).r = (red)) +#define PPM_PUTG(p,grn) ((p).g = (grn)) +#define PPM_PUTB(p,blu) ((p).b = (blu)) + +#define PPM_ASSIGN(p,red,grn,blu) { (p).r = (red); (p).g = (grn); (p).b = (blu); } +#define PPM_EQUAL(p,q) ( (p).r == (q).r && (p).g == (q).g && (p).b == (q).b ) +#define PNM_ASSIGN1(x,v) PPM_ASSIGN(x,0,0,v) + +#define PPM_DEPTH(newp,p,oldmaxval,newmaxval) \ + PPM_ASSIGN( (newp), \ + ( (int) PPM_GETR(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval), \ + ( (int) PPM_GETG(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval), \ + ( (int) PPM_GETB(p) * (newmaxval) + (oldmaxval) / 2 ) / (oldmaxval) ) -// Got to undefine the stupid macros that pbmplus leaves us with. -#ifdef index - #undef index - #undef rindex -#endif +// pnm defines these functions, and it's easier to emulate them than +// to rewrite the code that calls them. +EXPCL_PANDA void pm_message(const char *format, ...); +EXPCL_PANDA void pm_error(const char *format, ...); // doesn't return. + +EXPCL_PANDA int pm_maxvaltobits(int maxval); +EXPCL_PANDA int pm_bitstomaxval(int bits); + +EXPCL_PANDA char *pm_allocrow(int cols, int size); +EXPCL_PANDA void pm_freerow(char *itrow); + +EXPCL_PANDA int pm_readbigshort(FILE *in, short *sP); +EXPCL_PANDA int pm_writebigshort(FILE *out, short s); +EXPCL_PANDA int pm_readbiglong(FILE *in, long *lP); +EXPCL_PANDA int pm_writebiglong(FILE *out, long l); +EXPCL_PANDA int pm_readlittleshort(FILE *in, short *sP); +EXPCL_PANDA int pm_writelittleshort(FILE *out, short s); +EXPCL_PANDA int pm_readlittlelong(FILE *in, long *lP); +EXPCL_PANDA int pm_writelittlelong(FILE *out, long l); + // These ratios are used to compute the brightness of a colored pixel; they // define the relative contributions of each of the components. @@ -54,12 +101,5 @@ static const double lumin_red = 0.299; static const double lumin_grn = 0.587; static const double lumin_blu = 0.114; -// A handy template function. -template -INLINE Type -bounds(const Type &value, const Type &lower, const Type &upper) { - return min(max(value, lower), upper); -} - #endif diff --git a/panda/src/pnmimage/pnmimage_composite1.cxx b/panda/src/pnmimage/pnmimage_composite1.cxx index 5a0f24072f..91512f8da9 100644 --- a/panda/src/pnmimage/pnmimage_composite1.cxx +++ b/panda/src/pnmimage/pnmimage_composite1.cxx @@ -1,5 +1,5 @@ - #include "config_pnmimage.cxx" #include "pnm-image-filter.cxx" +#include "pnmbitio.cxx" #include "pnmFileType.cxx" diff --git a/panda/src/pnmimage/pnmimage_composite2.cxx b/panda/src/pnmimage/pnmimage_composite2.cxx index fdedd339ee..fde48347f7 100644 --- a/panda/src/pnmimage/pnmimage_composite2.cxx +++ b/panda/src/pnmimage/pnmimage_composite2.cxx @@ -1,6 +1,8 @@ - #include "pnmImage.cxx" #include "pnmImageHeader.cxx" #include "pnmReader.cxx" #include "pnmWriter.cxx" #include "pnmFileTypeRegistry.cxx" +#include "pnmimage_base.cxx" +#include "ppmcmap.cxx" + diff --git a/panda/src/pnmimage/pnmminmax.h b/panda/src/pnmimage/pnmminmax.h deleted file mode 100644 index 42b40bcb63..0000000000 --- a/panda/src/pnmimage/pnmminmax.h +++ /dev/null @@ -1,48 +0,0 @@ -// Filename: pnmminmax.h -// Created by: drose (23Aug96) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://www.panda3d.org/license.txt . -// -// To contact the maintainers of this program write to -// panda3d@yahoogroups.com . -// -//////////////////////////////////////////////////////////////////// - -#ifndef _PNMMINMAX_H_ -#define _PNMMINMAX_H_ - -#include - -#include - -// We now inherit these functions from STL. - -/* -template -inline Type -max(const Type &a, const Type &b) { - return (a -inline Type -min(const Type &a, const Type &b) { - return (a -inline Type -bounds(const Type &value, const Type &lower, const Type &upper) { - return min(max(value, lower), upper); -} - -#endif diff --git a/panda/src/pnm/libppm3.c b/panda/src/pnmimage/ppmcmap.cxx similarity index 87% rename from panda/src/pnm/libppm3.c rename to panda/src/pnmimage/ppmcmap.cxx index 4fe33df3b6..071a40585c 100644 --- a/panda/src/pnm/libppm3.c +++ b/panda/src/pnmimage/ppmcmap.cxx @@ -12,9 +12,7 @@ ** implied warranty. */ -#include "ppm.h" #include "ppmcmap.h" -#include "libppm.h" #define HASH_SIZE 20023 @@ -25,10 +23,9 @@ #endif /*PPM_PACKCOLORS*/ colorhist_vector -ppm_computecolorhist( pixels, cols, rows, maxcolors, colorsP ) - pixel** pixels; - int cols, rows, maxcolors; - int* colorsP; +ppm_computecolorhist(pixel** pixels, + int cols, int rows, int maxcolors, + int* colorsP) { colorhash_table cht; colorhist_vector chv; @@ -42,11 +39,11 @@ ppm_computecolorhist( pixels, cols, rows, maxcolors, colorsP ) } void -ppm_addtocolorhist( chv, colorsP, maxcolors, colorP, value, position ) - colorhist_vector chv; - pixel* colorP; - int* colorsP; - int maxcolors, value, position; +ppm_addtocolorhist(colorhist_vector chv, + int* colorsP, + int maxcolors, + pixel* colorP, + int value, int position) { int i, j; @@ -81,10 +78,9 @@ ppm_addtocolorhist( chv, colorsP, maxcolors, colorP, value, position ) } colorhash_table -ppm_computecolorhash( pixels, cols, rows, maxcolors, colorsP ) - pixel** pixels; - int cols, rows, maxcolors; - int* colorsP; +ppm_computecolorhash(pixel** pixels, + int cols, int rows, int maxcolors, + int* colorsP) { colorhash_table cht; register pixel* pP; @@ -141,10 +137,9 @@ ppm_alloccolorhash( ) } int -ppm_addtocolorhash( cht, colorP, value ) - colorhash_table cht; - pixel* colorP; - int value; +ppm_addtocolorhash(colorhash_table cht, + pixel* colorP, + int value) { register int hash; register colorhist_list chl; @@ -161,9 +156,8 @@ ppm_addtocolorhash( cht, colorP, value ) } colorhist_vector -ppm_colorhashtocolorhist( cht, maxcolors ) - colorhash_table cht; - int maxcolors; +ppm_colorhashtocolorhist(colorhash_table cht, + int maxcolors) { colorhist_vector chv; colorhist_list chl; @@ -190,9 +184,8 @@ ppm_colorhashtocolorhist( cht, maxcolors ) } colorhash_table -ppm_colorhisttocolorhash( chv, colors ) - colorhist_vector chv; - int colors; +ppm_colorhisttocolorhash(colorhist_vector chv, + int colors) { colorhash_table cht; int i, hash; @@ -223,9 +216,8 @@ ppm_colorhisttocolorhash( chv, colors ) } int -ppm_lookupcolor( cht, colorP ) - colorhash_table cht; - pixel* colorP; +ppm_lookupcolor(colorhash_table cht, + pixel* colorP) { int hash; colorhist_list chl; @@ -239,15 +231,13 @@ ppm_lookupcolor( cht, colorP ) } void -ppm_freecolorhist( chv ) - colorhist_vector chv; +ppm_freecolorhist(colorhist_vector chv) { free( (char*) chv ); } void -ppm_freecolorhash( cht ) - colorhash_table cht; +ppm_freecolorhash(colorhash_table cht) { int i; colorhist_list chl, chlnext; diff --git a/panda/src/pnm/ppmcmap.h b/panda/src/pnmimage/ppmcmap.h similarity index 67% rename from panda/src/pnm/ppmcmap.h rename to panda/src/pnmimage/ppmcmap.h index 2a2eb3db5c..cca3d854ce 100644 --- a/panda/src/pnm/ppmcmap.h +++ b/panda/src/pnmimage/ppmcmap.h @@ -6,6 +6,9 @@ #ifndef PPMCMAP_H #define PPMCMAP_H +#include "pandabase.h" +#include "pnmimage_base.h" + typedef struct colorhist_item* colorhist_vector; struct colorhist_item { @@ -23,7 +26,7 @@ struct colorhist_list_item EXPCL_PANDA colorhist_vector ppm_computecolorhist( pixel** pixels, int cols, int rows, int maxcolors, int* colorsP ); /* Returns a colorhist *colorsP long (with space allocated for maxcolors. */ -void ppm_addtocolorhist ARGS(( colorhist_vector chv, int* colorsP, int maxcolors, pixel* colorP, int value, int position )); +void ppm_addtocolorhist ( colorhist_vector chv, int* colorsP, int maxcolors, pixel* colorP, int value, int position ); EXPCL_PANDA void ppm_freecolorhist( colorhist_vector chv ); @@ -32,18 +35,18 @@ EXPCL_PANDA void ppm_freecolorhist( colorhist_vector chv ); typedef colorhist_list* colorhash_table; -colorhash_table ppm_computecolorhash ARGS(( pixel** pixels, int cols, int rows, int maxcolors, int* colorsP )); +colorhash_table ppm_computecolorhash ( pixel** pixels, int cols, int rows, int maxcolors, int* colorsP ); EXPCL_PANDA int ppm_lookupcolor( colorhash_table cht, pixel* colorP ); -colorhist_vector ppm_colorhashtocolorhist ARGS(( colorhash_table cht, int maxcolors )); +colorhist_vector ppm_colorhashtocolorhist ( colorhash_table cht, int maxcolors ); EXPCL_PANDA colorhash_table ppm_colorhisttocolorhash( colorhist_vector chv, int colors ); -int ppm_addtocolorhash ARGS(( colorhash_table cht, pixel* colorP, int value )); +int ppm_addtocolorhash ( colorhash_table cht, pixel* colorP, int value ); /* Returns -1 on failure. */ -colorhash_table ppm_alloccolorhash ARGS(( void )); +colorhash_table ppm_alloccolorhash ( void ); void ppm_freecolorhash( colorhash_table cht ); diff --git a/panda/src/pnmimagetypes/Sources.pp b/panda/src/pnmimagetypes/Sources.pp index c12dd29899..8b239ce07b 100644 --- a/panda/src/pnmimagetypes/Sources.pp +++ b/panda/src/pnmimagetypes/Sources.pp @@ -5,7 +5,7 @@ #begin lib_target #define TARGET pnmimagetypes #define LOCAL_LIBS \ - pnm pnmimage + pnmimage #define COMBINED_SOURCES \ $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx \ @@ -14,7 +14,7 @@ #define SOURCES \ config_pnmimagetypes.h pnmFileTypeAlias.h pnmFileTypeBMP.h \ - pnmFileTypeIMG.h pnmFileTypePNM.h pnmFileTypeRadiance.h \ + pnmFileTypeIMG.h pnmFileTypeRadiance.h \ pnmFileTypeSGI.h pnmFileTypeSoftImage.h \ pnmFileTypeTGA.h pnmFileTypeYUV.h color.c colrops.c resolu.c \ header.c \ @@ -25,7 +25,7 @@ #define INCLUDED_SOURCES \ config_pnmimagetypes.cxx pnmFileTypeAlias.cxx \ pnmFileTypeBMPReader.cxx pnmFileTypeBMPWriter.cxx \ - pnmFileTypeIMG.cxx pnmFileTypePNM.cxx pnmFileTypeBMP.cxx \ + pnmFileTypeIMG.cxx pnmFileTypeBMP.cxx \ pnmFileTypeRadiance.cxx pnmFileTypeSGI.cxx \ pnmFileTypeSGIReader.cxx pnmFileTypeSGIWriter.cxx \ pnmFileTypeSoftImage.cxx \ diff --git a/panda/src/pnmimagetypes/bmp.h b/panda/src/pnmimagetypes/bmp.h index 4cf4aab810..1910443d71 100644 --- a/panda/src/pnmimagetypes/bmp.h +++ b/panda/src/pnmimagetypes/bmp.h @@ -19,9 +19,8 @@ #ifndef _BMP_H_ #define _BMP_H_ -#include - -#include "pbmplus.h" +#include "pandabase.h" +#include "pnmimage_base.h" /* prototypes */ static unsigned long BMPlenfileheader(int classv); diff --git a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx index e05bd16463..b0f42e5b6c 100644 --- a/panda/src/pnmimagetypes/config_pnmimagetypes.cxx +++ b/panda/src/pnmimagetypes/config_pnmimagetypes.cxx @@ -17,7 +17,6 @@ //////////////////////////////////////////////////////////////////// #include "config_pnmimagetypes.h" -#include "pnmFileTypePNM.h" #include "pnmFileTypeSGI.h" #include "pnmFileTypeAlias.h" #include "pnmFileTypeRadiance.h" @@ -123,7 +122,6 @@ init_libpnmimagetypes() { initialized = true; init_libpnmimage(); - PNMFileTypePNM::init_type(); PNMFileTypeSGI::init_type(); PNMFileTypeAlias::init_type(); PNMFileTypeRadiance::init_type(); @@ -169,7 +167,6 @@ init_libpnmimagetypes() { // Register each type with the PNMFileTypeRegistry. PNMFileTypeRegistry *tr = PNMFileTypeRegistry::get_ptr(); - tr->register_type(new PNMFileTypePNM); tr->register_type(new PNMFileTypeSGI); tr->register_type(new PNMFileTypeAlias); tr->register_type(new PNMFileTypeRadiance); @@ -189,7 +186,6 @@ init_libpnmimagetypes() { #endif // Also register with the Bam reader. - PNMFileTypePNM::register_with_read_factory(); PNMFileTypeSGI::register_with_read_factory(); PNMFileTypeAlias::register_with_read_factory(); PNMFileTypeRadiance::register_with_read_factory(); diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx index 3aaefd3332..51be2bac10 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMPReader.cxx @@ -18,11 +18,8 @@ #include "pnmFileTypeBMP.h" #include "config_pnmimagetypes.h" - -extern "C" { - #include "bmp.h" - #include "../pnm/bitio.h" -} +#include "bmp.h" +#include "pnmbitio.h" // Much code in this file is borrowed from Netpbm, specifically bmptoppm.c. /* @@ -46,17 +43,17 @@ extern "C" { * Utilities */ -static int GetByte ARGS((FILE * fp)); -static short GetShort ARGS((FILE * fp)); -static long GetLong ARGS((FILE * fp)); -static void readto ARGS((FILE *fp, unsigned long *ppos, unsigned long dst)); -static void BMPreadfileheader ARGS((FILE *fp, unsigned long *ppos, - unsigned long *poffBits)); -static void BMPreadinfoheader ARGS((FILE *fp, unsigned long *ppos, +static int GetByte (FILE * fp); +static short GetShort (FILE * fp); +static long GetLong (FILE * fp); +static void readto (FILE *fp, unsigned long *ppos, unsigned long dst); +static void BMPreadfileheader (FILE *fp, unsigned long *ppos, + unsigned long *poffBits); +static void BMPreadinfoheader (FILE *fp, unsigned long *ppos, unsigned long *pcx, unsigned long *pcy, unsigned short *pcBitCount, - int *pclassv)); -static int BMPreadrgbtable ARGS((FILE *fp, unsigned long *ppos, - unsigned short cBitCount, int classv, pixval *R, pixval *G, pixval *B)); + int *pclassv); +static int BMPreadrgbtable (FILE *fp, unsigned long *ppos, + unsigned short cBitCount, int classv, pixval *R, pixval *G, pixval *B); static const char *ifname = "BMP"; static char er_read[] = "%s: read error"; diff --git a/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx index c2382dc8a1..fae6e3db34 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeBMPWriter.cxx @@ -19,14 +19,12 @@ #include "pnmFileTypeBMP.h" #include "config_pnmimagetypes.h" -#include -#include +#include "pnmImage.h" +#include "pnmWriter.h" -extern "C" { - #include "bmp.h" - #include "../pnm/ppmcmap.h" - #include "../pnm/bitio.h" -} +#include "bmp.h" +#include "ppmcmap.h" +#include "pnmbitio.h" // Much code in this file is borrowed from Netpbm, specifically ppmtobmp.c. /* @@ -55,19 +53,19 @@ extern "C" { static char er_write[] = "stdout: write error"; /* prototypes */ -static void PutByte ARGS((FILE *fp, char v)); -static void PutShort ARGS((FILE *fp, short v)); -static void PutLong ARGS((FILE *fp, long v)); -static int BMPwritefileheader ARGS((FILE *fp, int classv, unsigned long bitcount, - unsigned long x, unsigned long y)); -static int BMPwriteinfoheader ARGS((FILE *fp, int classv, unsigned long bitcount, - unsigned long x, unsigned long y)); -static int BMPwritergb ARGS((FILE *fp, int classv, pixval R, pixval G, pixval B)); -static int BMPwritergbtable ARGS((FILE *fp, int classv, int bpp, int colors, - pixval *R, pixval *G, pixval *B)); -static int colorstobpp ARGS((int colors)); -static void BMPEncode ARGS((FILE *fp, int classv, int x, int y, pixel **pixels, - int colors, colorhash_table cht, pixval *R, pixval *G, pixval *B)); +static void PutByte (FILE *fp, char v); +static void PutShort (FILE *fp, short v); +static void PutLong (FILE *fp, long v); +static int BMPwritefileheader (FILE *fp, int classv, unsigned long bitcount, + unsigned long x, unsigned long y); +static int BMPwriteinfoheader (FILE *fp, int classv, unsigned long bitcount, + unsigned long x, unsigned long y); +static int BMPwritergb (FILE *fp, int classv, pixval R, pixval G, pixval B); +static int BMPwritergbtable (FILE *fp, int classv, int bpp, int colors, + pixval *R, pixval *G, pixval *B); +static int colorstobpp (int colors); +static void BMPEncode (FILE *fp, int classv, int x, int y, pixel **pixels, + int colors, colorhash_table cht, pixval *R, pixval *G, pixval *B); static void PutByte( FILE *fp, diff --git a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx deleted file mode 100644 index 86daaa5439..0000000000 --- a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx +++ /dev/null @@ -1,363 +0,0 @@ -// Filename: pnmFileTypePNM.cxx -// Created by: drose (04Apr98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://www.panda3d.org/license.txt . -// -// To contact the maintainers of this program write to -// panda3d@yahoogroups.com . -// -//////////////////////////////////////////////////////////////////// - -#include "pnmFileTypePNM.h" -#include "config_pnmimagetypes.h" - -#include -#include - -extern "C" { -#include "../pnm/pnm.h" -#include "../pnm/ppm.h" -#include "../pnm/pgm.h" -#include "../pnm/pbm.h" -#include "../pnm/libppm.h" -#include "../pnm/libpgm.h" -#include "../pnm/libpbm.h" -} - -static const char * const extensions_PNM[] = { - "pbm", "ppm", "pnm" -}; -static const int num_extensions_PNM = sizeof(extensions_PNM) / sizeof(const char *); - -TypeHandle PNMFileTypePNM::_type_handle; - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -PNMFileTypePNM:: -PNMFileTypePNM() { -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::get_name -// Access: Public, Virtual -// Description: Returns a few words describing the file type. -//////////////////////////////////////////////////////////////////// -string PNMFileTypePNM:: -get_name() const { - return "NetPBM-style PBM/PPM/PNM"; -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::get_num_extensions -// Access: Public, Virtual -// Description: Returns the number of different possible filename -// extensions_PNM associated with this particular file type. -//////////////////////////////////////////////////////////////////// -int PNMFileTypePNM:: -get_num_extensions() const { - return num_extensions_PNM; -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::get_extension -// Access: Public, Virtual -// Description: Returns the nth possible filename extension -// associated with this particular file type, without a -// leading dot. -//////////////////////////////////////////////////////////////////// -string PNMFileTypePNM:: -get_extension(int n) const { - nassertr(n >= 0 && n < num_extensions_PNM, string()); - return extensions_PNM[n]; -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::get_suggested_extension -// Access: Public, Virtual -// Description: Returns a suitable filename extension (without a -// leading dot) to suggest for files of this type, or -// empty string if no suggestions are available. -//////////////////////////////////////////////////////////////////// -string PNMFileTypePNM:: -get_suggested_extension() const { - return "pnm"; -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::has_magic_number -// Access: Public, Virtual -// Description: Returns true if this particular file type uses a -// magic number to identify it, false otherwise. -//////////////////////////////////////////////////////////////////// -bool PNMFileTypePNM:: -has_magic_number() const { - return true; -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::matches_magic_number -// Access: Public, Virtual -// Description: Returns true if the indicated "magic number" byte -// stream (the initial few bytes read from the file) -// matches this particular file type, false otherwise. -//////////////////////////////////////////////////////////////////// -bool PNMFileTypePNM:: -matches_magic_number(const string &magic_number) const { - return (magic_number.size() >= 2) && - magic_number[0] == 'P' && - (magic_number[1] >= '1' && magic_number[1] <= '6'); -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::make_reader -// Access: Public, Virtual -// Description: Allocates and returns a new PNMReader suitable for -// reading from this file type, if possible. If reading -// from this file type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// -PNMReader *PNMFileTypePNM:: -make_reader(FILE *file, bool owns_file, const string &magic_number) { - init_pnm(); - return new Reader(this, file, owns_file, magic_number); -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::make_writer -// Access: Public, Virtual -// Description: Allocates and returns a new PNMWriter suitable for -// reading from this file type, if possible. If writing -// files of this type is not supported, returns NULL. -//////////////////////////////////////////////////////////////////// -PNMWriter *PNMFileTypePNM:: -make_writer(FILE *file, bool owns_file) { - init_pnm(); - return new Writer(this, file, owns_file); -} - - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Reader::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -PNMFileTypePNM::Reader:: -Reader(PNMFileType *type, FILE *file, bool owns_file, string magic_number) : - PNMReader(type, file, owns_file) -{ - if (!read_magic_number(_file, magic_number, 2)) { - // No magic number. No image. - if (pnmimage_pnm_cat.is_debug()) { - pnmimage_pnm_cat.debug() - << "PNM file appears to be empty.\n"; - } - _is_valid = false; - return; - } - - // pnm_pbmmaxval = PNM_MAXMAXVAL; /* use larger value for better results */ - - _ftype = - ((unsigned char)magic_number[0] << 8) | - (unsigned char)magic_number[1]; - - switch ( PNM_FORMAT_TYPE(_ftype) ) { - case PPM_TYPE: - ppm_readppminitrest( file, &_x_size, &_y_size, &_maxval ); - _num_channels = 3; - break; - - case PGM_TYPE: - pgm_readpgminitrest( file, &_x_size, &_y_size, &_maxval ); - _num_channels = 1; - break; - - case PBM_TYPE: - pbm_readpbminitrest( file, &_x_size, &_y_size ); - _num_channels = 1; - _maxval = pnm_pbmmaxval; - break; - - default: - _is_valid = false; - } - - if (pnmimage_pnm_cat.is_debug()) { - if (is_valid()) { - pnmimage_pnm_cat.debug() - << "Reading "; - switch (PNM_FORMAT_TYPE(_ftype)) { - case PPM_TYPE: - pnmimage_pnm_cat.debug(false) << "PPM"; - break; - case PGM_TYPE: - pnmimage_pnm_cat.debug(false) << "PGM"; - break; - case PBM_TYPE: - pnmimage_pnm_cat.debug(false) << "PBM"; - break; - } - pnmimage_pnm_cat.debug(false) - << " " << *this << "\n"; - } else { - pnmimage_pnm_cat.debug() - << "File is not a valid PNM image.\n"; - } - } -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Reader::supports_read_row -// Access: Public, Virtual -// Description: Returns true if this particular PNMReader supports a -// streaming interface to reading the data: that is, it -// is capable of returning the data one row at a time, -// via repeated calls to read_row(). Returns false if -// the only way to read from this file is all at once, -// via read_data(). -//////////////////////////////////////////////////////////////////// -bool PNMFileTypePNM::Reader:: -supports_read_row() const { - return true; -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Reader::read_row -// Access: Public, Virtual -// Description: If supports_read_row(), above, returns true, this -// function may be called repeatedly to read the image, -// one horizontal row at a time, beginning from the top. -// Returns true if the row is successfully read, false -// if there is an error or end of file. -//////////////////////////////////////////////////////////////////// -bool PNMFileTypePNM::Reader:: -read_row(xel *row_data, xelval *) { - if (!is_valid()) { - return false; - } - pnm_readpnmrow(_file, row_data, _x_size, _maxval, _ftype); - return true; -} - - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Writer::Constructor -// Access: Public -// Description: -//////////////////////////////////////////////////////////////////// -PNMFileTypePNM::Writer:: -Writer(PNMFileType *type, FILE *file, bool owns_file) : - PNMWriter(type, file, owns_file) -{ -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Writer::supports_write_row -// Access: Public, Virtual -// Description: Returns true if this particular PNMWriter supports a -// streaming interface to writing the data: that is, it -// is capable of writing the image one row at a time, -// via repeated calls to write_row(). Returns false if -// the only way to write from this file is all at once, -// via write_data(). -//////////////////////////////////////////////////////////////////// -bool PNMFileTypePNM::Writer:: -supports_write_row() const { - return true; -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Writer::write_header -// Access: Public, Virtual -// Description: If supports_write_row(), above, returns true, this -// function may be called to write out the image header -// in preparation to writing out the image data one row -// at a time. Returns true if the header is -// successfully written, false if there is an error. -// -// It is the user's responsibility to fill in the header -// data via calls to set_x_size(), set_num_channels(), -// etc., or copy_header_from(), before calling -// write_header(). -//////////////////////////////////////////////////////////////////// -bool PNMFileTypePNM::Writer:: -write_header() { - switch (get_color_type()) { - case PNMImageHeader::CT_grayscale: - case PNMImageHeader::CT_two_channel: - _pnm_format = PGM_TYPE; - break; - - case PNMImageHeader::CT_color: - case PNMImageHeader::CT_four_channel: - _pnm_format = PPM_TYPE; - break; - - default: - break; - } - - pnm_writepnminit(_file, _x_size, _y_size, _maxval, _pnm_format, 0); - return true; -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::Writer::write_row -// Access: Public, Virtual -// Description: If supports_write_row(), above, returns true, this -// function may be called repeatedly to write the image, -// one horizontal row at a time, beginning from the top. -// Returns true if the row is successfully written, -// false if there is an error. -// -// You must first call write_header() before writing the -// individual rows. It is also important to delete the -// PNMWriter class after successfully writing the last -// row. Failing to do this may result in some data not -// getting flushed! -//////////////////////////////////////////////////////////////////// -bool PNMFileTypePNM::Writer:: -write_row(xel *row_data, xelval *) { - pnm_writepnmrow(_file, row_data, _x_size, _maxval, _pnm_format, 0); - - return true; -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::register_with_read_factory -// Access: Public, Static -// Description: Registers the current object as something that can be -// read from a Bam file. -//////////////////////////////////////////////////////////////////// -void PNMFileTypePNM:: -register_with_read_factory() { - BamReader::get_factory()-> - register_factory(get_class_type(), make_PNMFileTypePNM); -} - -//////////////////////////////////////////////////////////////////// -// Function: PNMFileTypePNM::make_PNMFileTypePNM -// Access: Protected, Static -// Description: This method is called by the BamReader when an object -// of this type is encountered in a Bam file; it should -// allocate and return a new object with all the data -// read. -// -// In the case of the PNMFileType objects, since these -// objects are all shared, we just pull the object from -// the registry. -//////////////////////////////////////////////////////////////////// -TypedWritable *PNMFileTypePNM:: -make_PNMFileTypePNM(const FactoryParams ¶ms) { - return PNMFileTypeRegistry::get_ptr()->get_type_by_handle(get_class_type()); -} diff --git a/panda/src/pnmimagetypes/pnmFileTypePNM.h b/panda/src/pnmimagetypes/pnmFileTypePNM.h deleted file mode 100644 index fc5571c891..0000000000 --- a/panda/src/pnmimagetypes/pnmFileTypePNM.h +++ /dev/null @@ -1,102 +0,0 @@ -// Filename: pnmFileTypePNM.h -// Created by: drose (17Jun00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://www.panda3d.org/license.txt . -// -// To contact the maintainers of this program write to -// panda3d@yahoogroups.com . -// -//////////////////////////////////////////////////////////////////// - -#ifndef PNMFILETYPEPNM_H -#define PNMFILETYPEPNM_H - -#include - -#include -#include -#include - -//////////////////////////////////////////////////////////////////// -// Class : PNMFileTypePNM -// Description : For reading and writing basic PNM files--*.pbm, -// *.ppm, *.pnm. -//////////////////////////////////////////////////////////////////// -class EXPCL_PANDA PNMFileTypePNM : public PNMFileType { -public: - PNMFileTypePNM(); - - virtual string get_name() const; - - virtual int get_num_extensions() const; - virtual string get_extension(int n) const; - virtual string get_suggested_extension() const; - - virtual bool has_magic_number() const; - virtual bool matches_magic_number(const string &magic_number) const; - - virtual PNMReader *make_reader(FILE *file, bool owns_file = true, - const string &magic_number = string()); - virtual PNMWriter *make_writer(FILE *file, bool owns_file = true); - -public: - class Reader : public PNMReader { - public: - Reader(PNMFileType *type, FILE *file, bool owns_file, string magic_number); - - virtual bool supports_read_row() const; - virtual bool read_row(xel *array, xelval *alpha); - - private: - int _ftype; - }; - - class Writer : public PNMWriter { - public: - Writer(PNMFileType *type, FILE *file, bool owns_file); - - virtual bool supports_write_row() const; - virtual bool write_header(); - virtual bool write_row(xel *array, xelval *alpha); - - private: - int _pnm_format; - }; - - - // The TypedWritable interface follows. -public: - static void register_with_read_factory(); - -protected: - static TypedWritable *make_PNMFileTypePNM(const FactoryParams ¶ms); - -public: - static TypeHandle get_class_type() { - return _type_handle; - } - static void init_type() { - PNMFileType::init_type(); - register_type(_type_handle, "PNMFileTypePNM", - PNMFileType::get_class_type()); - } - virtual TypeHandle get_type() const { - return get_class_type(); - } - virtual TypeHandle force_init_type() {init_type(); return get_class_type();} - -private: - static TypeHandle _type_handle; -}; - -#endif - - diff --git a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx index a5113862b9..13ad29324a 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTGA.cxx @@ -49,10 +49,10 @@ #include "pnmFileTypeTGA.h" #include "config_pnmimagetypes.h" -#include -#include +#include "pnmFileTypeRegistry.h" +#include "bamReader.h" +#include "pnmimage_base.h" -#include #include static const char * const extensions_TGA[] = { diff --git a/panda/src/pnmimagetypes/pnmFileTypeTGA.h b/panda/src/pnmimagetypes/pnmFileTypeTGA.h index 2062dd618f..2c73c9a6e6 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTGA.h +++ b/panda/src/pnmimagetypes/pnmFileTypeTGA.h @@ -19,15 +19,13 @@ #ifndef PNMFILETYPETGA_H #define PNMFILETYPETGA_H -#include +#include "pandabase.h" -#include -#include -#include - -extern "C" { -#include -} +#include "pnmFileType.h" +#include "pnmReader.h" +#include "pnmWriter.h" +#include "ppmcmap.h" +#include "pnmimage_base.h" struct ImageHeader; diff --git a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx index 7e40ef04d1..249ddeb1f3 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx @@ -19,15 +19,15 @@ #include "pnmFileTypeTIFF.h" #include "config_pnmimagetypes.h" -#include -#include +#include "pnmFileTypeRegistry.h" +#include "bamReader.h" +#include "ppmcmap.h" // Tiff will want to re-typedef these things. #define int32 tiff_int32 #define uint32 tiff_uint32 extern "C" { -#include "../pnm/ppmcmap.h" #include #include } diff --git a/panda/src/pnmimagetypes/pnmimagetypes_composite1.cxx b/panda/src/pnmimagetypes/pnmimagetypes_composite1.cxx index dd8a1ebb4e..4d03234b41 100644 --- a/panda/src/pnmimagetypes/pnmimagetypes_composite1.cxx +++ b/panda/src/pnmimagetypes/pnmimagetypes_composite1.cxx @@ -4,7 +4,6 @@ #include "pnmFileTypeBMPReader.cxx" #include "pnmFileTypeBMPWriter.cxx" #include "pnmFileTypeIMG.cxx" -#include "pnmFileTypePNM.cxx" #include "pnmFileTypeBMP.cxx" #include "pnmFileTypeRadiance.cxx"