home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-08-16 | 34.7 KB | 1,333 lines |
- Newsgroups: comp.sources.misc
- From: danisch@ira.uka.de (Hadmut Danisch)
- Subject: v39i004: hpcdtoppm - convert Photo-CD file into portable pixmap v0.5pl1, Part03/03
- Message-ID: <1993Aug16.204136.22222@sparky.sterling.com>
- X-Md4-Signature: 5c3d5441541b6df87d4b11306f99467c
- Sender: kent@sparky.sterling.com (Kent Landfield)
- Organization: Sterling Software
- Date: Mon, 16 Aug 1993 20:41:36 GMT
- Approved: kent@sparky.sterling.com
-
- Submitted-by: danisch@ira.uka.de (Hadmut Danisch)
- Posting-number: Volume 39, Issue 4
- Archive-name: hpcdtoppm/part03
- Environment: Photo-CD
- Supersedes: hpcdtoppm: Volume 34, Issue 83
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: hpcdtoppm.0.5.pl1/Adding_code hpcdtoppm.0.5.pl1/Changes
- # hpcdtoppm.0.5.pl1/Examples hpcdtoppm.0.5.pl1/README
- # hpcdtoppm.0.5.pl1/README.TOO hpcdtoppm.0.5.pl1/ReadMe.NeXT
- # hpcdtoppm.0.5.pl1/ReadMe.SGI hpcdtoppm.0.5.pl1/color.c
- # hpcdtoppm.0.5.pl1/config.h hpcdtoppm.0.5.pl1/hpcdtoppm.h
- # hpcdtoppm.0.5.pl1/ppm.c
- # Wrapped by kent@sparky on Mon Aug 16 10:49:23 1993
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 3 (of 3)."'
- if test -f 'hpcdtoppm.0.5.pl1/Adding_code' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'hpcdtoppm.0.5.pl1/Adding_code'\"
- else
- echo shar: Extracting \"'hpcdtoppm.0.5.pl1/Adding_code'\" \(2027 characters\)
- sed "s/^X//" >'hpcdtoppm.0.5.pl1/Adding_code' <<'END_OF_FILE'
- XSeveral people were changing the output image format
- Xof the decoder or asked for a different output format.
- X
- Xpbmplus enables the transformation to every image
- Xformat, but sometimes it is better to have the
- Xformat "inside". Therefore v0.5 is able to keep several
- Xformat 'drivers'.
- X
- X
- XTo add a new output format:
- X
- X- Append a new tag to the enum type OUTFOR in hpcdtoppm.h
- X
- X- change O_DEFAULT to this tag in config.h if you want to
- X have this format as the default format.
- X
- X- Insert a new 'if(...){...}' contruct to the procedure
- X parseargs in main.c after the comment "Output options".
- X
- X- Insert description text to error.c and hpcdtoppm.man.
- X
- X- If your format needs only grayscale data, append your
- X tag to the line "monochrome=(outfor==O_PGM)|| ..."
- X in the main procedure in main.c .
- X
- X- If your format uses the paper size values, append your
- X tag to the line "paper=(outfor==O_PS)|| ..."
- X in the main procedure in main.c .
- X
- X- Insert your tag into the switch-statement in the
- X procedure colconvert in color.c. If you need a
- X 8-bit-grayscale or 24-bit-rgb model, you just
- X have to insert a "case O_YourTag :" . Otherwise
- X you have to write your own colorconversion.
- X
- X- Insert your tag and procedure name into the switch-
- X statement in the procedure writepicture in output.c.
- X If you have a three-plane-image you can use the do_3plane
- X procedure with a pointer to your format writing
- X procedure as the first argument, if you have one
- X image plane, use the do_1plane. Otherwise write
- X a similar do_nplane procedure.
- X
- X- Write a procedure, which produces your format. You
- X should use the parameter scheme as defined for the
- X driver types OUT3PL and OUT1PL in hpcdtoppm.h.
- X
- X This means:
- X - a FILE *pointer to the output file
- X - image width and height.
- X
- X - for each image plane the triple:
- X - a pointer to the upper left position
- X - a relative row step ( in bytes )
- X - a relative column step ( in bytes )
- X
- X- If it works, let me know it. :-) Send mail to
- X danisch@ira.uka.de .
- X
- X
- X
- XHadmut
- X
- X
- X
- X
- END_OF_FILE
- if test 2027 -ne `wc -c <'hpcdtoppm.0.5.pl1/Adding_code'`; then
- echo shar: \"'hpcdtoppm.0.5.pl1/Adding_code'\" unpacked with wrong size!
- fi
- # end of 'hpcdtoppm.0.5.pl1/Adding_code'
- fi
- if test -f 'hpcdtoppm.0.5.pl1/Changes' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'hpcdtoppm.0.5.pl1/Changes'\"
- else
- echo shar: Extracting \"'hpcdtoppm.0.5.pl1/Changes'\" \(1816 characters\)
- sed "s/^X//" >'hpcdtoppm.0.5.pl1/Changes' <<'END_OF_FILE'
- XChanges of hpcdtoppm:
- X
- Xv0.5 pl1:
- X
- X- Bug fixed in main.c, procedure f_ov. When writing all the
- X images from overview files, a lot of file descriptors were
- X opened, but never closed. This produced write errors if the
- X machine has not enough file descriptors.
- X
- X- procedure clear renamed to clearimpl to avoid collision with
- X other libraries
- X
- X- data types OUTGRAY and OUTRGB renamed to OUT1PL and OUT3PL,
- X these data types are not bound to special color models.
- X
- X- gsave/grestore added to postscript output
- X
- Xv0.5:
- X
- X- Bug fixed in pgm writing procedure
- X
- X- Missing ':' added in BoundingBox line of encapsulated
- X Postscript
- X
- X- postscript output with Floyd-Steinberg dithering added
- X
- X- orientation chooser for contact sheet option -C
- X
- X- accepts input from stdin (give '-' as filename)
- X
- X- -S option for subrectangles
- X
- X- procedure definitions in ANSI-C
- X
- X- "turn on head" added.
- X
- X
- Xv0.4:
- X
- X- Additional Options -m, -pos, -rep, -crop
- X
- X- pgm output added
- X
- X- postscript output added
- X
- X- Flip options
- X
- X- color corrections
- X
- X- primitive form of contact sheet
- X
- X- simple method of jumping over reading errors in
- X Huffman code
- X
- X- optional Huffman-Lookuptable for speedup
- X
- X
- X
- Xv0.3:
- X- Additional Options -x, -a and -ycc
- X
- X- bcopy thrown out.
- X
- X- New datatype sBYTE for char. This fixes the problem with
- X compilers which have the char unsigned. These got some
- X 'snow' in their pictures (merry christmas :-).
- X
- X- Address arithmetik bug fixed in writepicture
- X
- Xv0.2:
- X
- X- Small workaround for strange behavior of address-calculation
- X of a c-compiler for NeXT.
- X
- X- Improved rounding for integer maths.
- X
- X- Thrown out floating arithmetic, changed color conversion to
- X integer fixed point.
- X
- X- PPM-writing-routines added. You can choose whether you
- X want to use pbmplus-routines or the included routines.
- X
- X- some ununused variables thrown out.
- X
- END_OF_FILE
- if test 1816 -ne `wc -c <'hpcdtoppm.0.5.pl1/Changes'`; then
- echo shar: \"'hpcdtoppm.0.5.pl1/Changes'\" unpacked with wrong size!
- fi
- # end of 'hpcdtoppm.0.5.pl1/Changes'
- fi
- if test -f 'hpcdtoppm.0.5.pl1/Examples' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'hpcdtoppm.0.5.pl1/Examples'\"
- else
- echo shar: Extracting \"'hpcdtoppm.0.5.pl1/Examples'\" \(1568 characters\)
- sed "s/^X//" >'hpcdtoppm.0.5.pl1/Examples' <<'END_OF_FILE'
- XThis are some examples of the use of hpcdtoppm, insert one
- Xof your images where a filename as img0010.pcd is used.
- X
- X"postscriptprinter" means something on your machine, what
- Xprints postscript output on paper.
- X
- X"xv" is a program for viewing images on X11.
- X
- X
- X
- Xhpcdtoppm img0005.pcd img0005.ppm
- X
- X converts the image img0005.pcd to the ppm-format with resolution
- X 128x192. Output into the file img0005.ppm
- X
- X
- Xhpcdtoppm -3 -crop img0005.pcd | xv -
- X
- X removes a black frame (some images are scanned with a black frame) and
- X displays the image with resolution 512x768 on a X11-display (24-bit if possible).
- X
- X
- Xhpcdtoppm -l -5 -s -pgm img0005.pcd img0005.pgm
- X
- X turns the images counter-clockwise to portrait, converts to
- X the 2048x3072 resolution, applies a sharpness-operator and writes
- X it as 8-Bit-grayscale pgm to the file img0005.pgm.
- X
- X
- Xhpcdtoppm -l -5 -c+ -psd img0005.pcd img0005.ps
- X
- X corrects the images brighter and converts to a 2048x3072 dithered
- X postscript image. Fits on a sheet of paper if used on a 300dpi printer.
- X
- Xhpcdtoppm -s -S 1300-1850 1000-1260 -5 img0010.pcd | xv -8 -
- X
- X displays a small subrectangle of the high resolution an your x11 screen.
- X
- Xhpcdtoppm -c+ -l -s -S 1300-1850 1000-1260 -5 -psd -pw 500 -dpi 300 img0010.pcd | postscriptprinter
- X
- X prints out a dithered small subrectangle of your image.
- X
- X
- Xhpcdtoppm -c+ -C 6 l -psd -dpi 300 -pw 500 overview.pcd |postscriptprinter
- X
- X prints an index print; play with the number 6.
- X
- X
- Xhpcdtoppm -c+ -C 4 n -psd -dpi 300 -pw 500 overview.pcd |postscriptprinter
- X
- X something similar
- X
- END_OF_FILE
- if test 1568 -ne `wc -c <'hpcdtoppm.0.5.pl1/Examples'`; then
- echo shar: \"'hpcdtoppm.0.5.pl1/Examples'\" unpacked with wrong size!
- fi
- # end of 'hpcdtoppm.0.5.pl1/Examples'
- fi
- if test -f 'hpcdtoppm.0.5.pl1/README' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'hpcdtoppm.0.5.pl1/README'\"
- else
- echo shar: Extracting \"'hpcdtoppm.0.5.pl1/README'\" \(3691 characters\)
- sed "s/^X//" >'hpcdtoppm.0.5.pl1/README' <<'END_OF_FILE'
- X
- XThis is Version 0.5 pl1 of hpcdtoppm, Hadmut's pcd to ppm converter.
- XIt has this name to be distinguishable in case someone
- Xelse is producing a program also called pcdtoppm.
- X
- XRead the README.TOO and edit the config.h and the Makefile !
- X
- XThis program converts Photo-CD-Images to the ppm-Format of
- Xpbmplus. You can compile the program in two ways:
- X
- X1. Use its own ppm-writing-routines. In this case
- X you don't need ppm-includes or libraries. You
- X have to define macro 'OWN_WRITE' in the source or
- X by compiler-option. I am not sure, whether the
- X format of the ppm-header is the same on non-unix
- X machines. If you get problems with line-endings
- X (things like CR, LF, CR/LF), modify the macro
- X PPM_Header.
- X
- X2. You can use the pbmplus-routines. In this case
- X you need some files from the pbmplus package to compile:
- X
- X ppm.h pgm.h pbm.h pbmplus.h libppm.a libpgm.a libpbm.a
- X
- X
- XIMPORTANT: Some older versions of the gcc have problems with
- Xoptimization. They produce buggy code. This code will not
- Xdie with 'segmentation fault' or something like that, it
- Xjust produces damaged images.
- X
- XI did not have detailed information of the file-format and
- Xmost of my information i got by staring at the hex-dumps
- Xof an image file. So i am not absolutly sure, whether it
- Xworks on all Photo-CDs, because there are some bytes in
- Xthe header which i don't understand. But it works on
- Xmy Photo-CD.
- X
- XNote that you will get a 24 bit image. You can view these
- Xfiles with xv, but if you have an 8-bit-screen you will
- Xsometimes have some color-defects (if you have an 1-bit-screen
- Xyou will often have a lot of color-defects :-).
- XIt will also take some time to show with xv.
- X
- XYou can produce nice overview prints if you get the icontact
- Xprogram of Mark B. Hanson and put something like
- X
- Xdecode pcd hpcdtoppm -1 -a
- X
- Xin your ~/.icrc
- X
- Xor by use of the pcdindex script of Pieter S. van der
- XMeulen in this distribution.
- X
- X
- XIf you compile the program on a machine other than
- XSPARC please send me a short email which machine
- Xyou are using, whether you had problems or which
- Xchanges you have made.
- X
- XIf you port the program to any machine, please tell me,
- Xwhat you did and where to get the program. Within the
- Xlast weeks i got a lot of mail asking for the special
- XAmiga/NeXT/SGI/... version. Read the Special.* files.
- X
- X
- X
- XThanks to
- X
- X- Adolf Mathias (mathias@ira.uka.de) for writing some of the
- X postscript drivers.
- X
- X- Pieter S. van der Meulen for the contact sheet script.
- X
- X- Jeff for finding out how to detect the orientation of the
- X Overview thumbnails [ Hi Jeff, how are you? :-) ]
- X
- X- A lot of people for sending mail about
- X compilation on MS-DOS and OS/2 and many other machines.
- X
- X- lots and lots of people for sending me their improvements of the code.
- X Sorry, but i can not read and analyze them all. I do not have so
- X much time for the decoder, its my hobby, not my job. Often i get
- X mail with a complete source and "Hi Hadmut, i have improved your
- X code. It is now faster/smaller/better/something_else." But i don't
- X know, *what* is changed. A simple diff doesn't work, they all were
- X reformatting my source completely and i do not have the time to
- X read all sources to find the real changes. There are a lot
- X of real good ideas, but *please* tell me, where is the beef.
- X
- X- lots of people sending me just a formatted version of my code.
- X Thanks to them all, and yes, i have indent(1). I prefer
- X this way of formatting C-source.
- X
- X
- X
- X
- XHadmut Danisch (danisch@ira.uka.de)
- XIAKS
- XUniversitaet Karlsruhe
- XPostfach 6980
- XAm Fasanengarten 5
- X
- XD-7500 Karlsruhe (old postcode until 30.6.93)
- XD-76128 Karlsruhe (new postcode from 1.7.93)
- X
- XGermany
- X
- XFAX: +49 721 696893
- XTel./FAX privat: +49 721 607306
- X
- X
- END_OF_FILE
- if test 3691 -ne `wc -c <'hpcdtoppm.0.5.pl1/README'`; then
- echo shar: \"'hpcdtoppm.0.5.pl1/README'\" unpacked with wrong size!
- fi
- # end of 'hpcdtoppm.0.5.pl1/README'
- fi
- if test -f 'hpcdtoppm.0.5.pl1/README.TOO' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'hpcdtoppm.0.5.pl1/README.TOO'\"
- else
- echo shar: Extracting \"'hpcdtoppm.0.5.pl1/README.TOO'\" \(1553 characters\)
- sed "s/^X//" >'hpcdtoppm.0.5.pl1/README.TOO' <<'END_OF_FILE'
- XHere are some additional informations for installing and use:
- X
- XI. Edit the config.h and the Makefile !
- X
- XII. Several people had 'snowy' images with v0.1 and v0.2.
- X This happens when the machine handles the standard
- X type char unsigned. Therefore the datatype sBYTE
- X was introduced as 'signed char'. If your compiler
- X doesn't understand this, change sBYTE to such a datatype
- X of your compiler or use a commandlineoption like
- X -DsBYTE=char .
- X
- XIII. Not every image contains all resolutions (especially images
- X from demo disks). You can't extract resolutions which are
- X not contained.
- X
- XIV. Some cdrom drives read more than the data sectors of the
- X PhotoCD files. They read additional sector headers etc.
- X In this case to have to write a little conversion tool.
- X
- X E.g.: Sony NEWS, model NWS-3720
- X Write a simple filter program, which takes the file,
- X cuts in slices of 0x920 size, takes out 0x800 data
- X with offset 8 of each slice and write them out in a new file.
- X
- X
- XV. There are some problems when compiling for MS-DOS or OS/2.
- X I don't like this, i don't have this and i don't use this.
- X Several people sent mail with tricks for compiling.
- X The important things are:
- X - Use the gcc compiler and
- X
- X - change the fopen parameters from "w" to "wb" and from "r" to "rb".
- X - or use the binmode.o routines.
- X
- XVI. On a Sun Workstation you can mount the Photo-CD as a high-sierra
- X file system with the command
- X mount -r -t hsfs /dev/sr0 /cdrom
- X
- X
- END_OF_FILE
- if test 1553 -ne `wc -c <'hpcdtoppm.0.5.pl1/README.TOO'`; then
- echo shar: \"'hpcdtoppm.0.5.pl1/README.TOO'\" unpacked with wrong size!
- fi
- # end of 'hpcdtoppm.0.5.pl1/README.TOO'
- fi
- if test -f 'hpcdtoppm.0.5.pl1/ReadMe.NeXT' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'hpcdtoppm.0.5.pl1/ReadMe.NeXT'\"
- else
- echo shar: Extracting \"'hpcdtoppm.0.5.pl1/ReadMe.NeXT'\" \(244 characters\)
- sed "s/^X//" >'hpcdtoppm.0.5.pl1/ReadMe.NeXT' <<'END_OF_FILE'
- X
- X
- XThere are at least two ports to the NeXT machine with
- Xgraphical user interface. One of them is called "pCD".
- X
- XSince i do not get informed about these ports, i don't
- Xknow on which version of hpcdtoppm they are based and
- Xwhere to get them.
- X
- X
- END_OF_FILE
- if test 244 -ne `wc -c <'hpcdtoppm.0.5.pl1/ReadMe.NeXT'`; then
- echo shar: \"'hpcdtoppm.0.5.pl1/ReadMe.NeXT'\" unpacked with wrong size!
- fi
- # end of 'hpcdtoppm.0.5.pl1/ReadMe.NeXT'
- fi
- if test -f 'hpcdtoppm.0.5.pl1/ReadMe.SGI' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'hpcdtoppm.0.5.pl1/ReadMe.SGI'\"
- else
- echo shar: Extracting \"'hpcdtoppm.0.5.pl1/ReadMe.SGI'\" \(345 characters\)
- sed "s/^X//" >'hpcdtoppm.0.5.pl1/ReadMe.SGI' <<'END_OF_FILE'
- X
- XThere is a special version of hpcdtoppm with extensions for
- XSGI machines. The extensions are written by
- X
- X Rodney Hoinkes
- X Head of Design Applications
- X Centre for Landscape Research
- X University of Toronto
- X Email: rodney@dgp.utoronto.ca
- X
- XThe SGI version is available via ftp at
- Xexplorer.dgp.toronto.edu (128.100.1.129) in pub/sgi/sgiphotocd .
- X
- X
- X
- END_OF_FILE
- if test 345 -ne `wc -c <'hpcdtoppm.0.5.pl1/ReadMe.SGI'`; then
- echo shar: \"'hpcdtoppm.0.5.pl1/ReadMe.SGI'\" unpacked with wrong size!
- fi
- # end of 'hpcdtoppm.0.5.pl1/ReadMe.SGI'
- fi
- if test -f 'hpcdtoppm.0.5.pl1/color.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'hpcdtoppm.0.5.pl1/color.c'\"
- else
- echo shar: Extracting \"'hpcdtoppm.0.5.pl1/color.c'\" \(4566 characters\)
- sed "s/^X//" >'hpcdtoppm.0.5.pl1/color.c' <<'END_OF_FILE'
- X/* hpcdtoppm (Hadmut's pcdtoppm) v0.5pl1
- X* Copyright (c) 1992, 1993 by Hadmut Danisch (danisch@ira.uka.de).
- X* Permission to use and distribute this software and its
- X* documentation for noncommercial use and without fee is hereby granted,
- X* provided that the above copyright notice appear in all copies and that
- X* both that copyright notice and this permission notice appear in
- X* supporting documentation. It is not allowed to sell this software in
- X* any way. This software is not public domain.
- X*/
- X
- X#include "hpcdtoppm.h"
- X
- Xextern sINT RGB_BitSh1,RGB_Maximum1;
- Xextern sINT RGB_F_LL;
- Xextern sINT RGB_F_C1,RGB_O_C1;
- Xextern sINT RGB_F_C2,RGB_O_C2;
- Xextern sINT RGB_F_G1,RGB_F_G2,RGB_O_G;
- Xextern uBYTE RGB_corr0[],RGB_corr1[],RGB_corr2[];
- X
- X
- Xstatic uBYTE *RGB_corr=0;
- Xstatic sINT T_L[256],T_R[256],T_G[256],T_g[256],T_B[256];
- X
- X#define slen 3072
- X
- X
- X
- Xstatic void initcorr(void)
- X {
- X switch(corrmode)
- X {case C_LINEAR: RGB_corr=RGB_corr0; break;
- X case C_DARK: RGB_corr=RGB_corr1; break;
- X case C_BRIGHT: RGB_corr=RGB_corr2; break;
- X default: error(E_INTERN);
- X }
- X }
- X
- X
- X
- Xstatic void initctable(void)
- X {sINT i;
- X static sINT init=0;
- X
- X if(init) return;
- X
- X init=1;
- X
- X initcorr();
- X
- X for(i=0;i<256;i++)
- X { T_L[i] = i * RGB_F_LL;
- X T_R[i] = i * RGB_F_C2 + RGB_O_C2;
- X T_G[i] = i * RGB_F_G1;
- X T_g[i] = i * RGB_F_G2 + RGB_O_G;
- X T_B[i] = i * RGB_F_C1 + RGB_O_C1;
- X }
- X
- X }
- X
- X
- Xstatic void ycctorgb(implane *l,implane *c1,implane *c2)
- X {dim x,y,w,h;
- X uBYTE *pl,*pc1,*pc2;
- X sINT red,green,blue;
- X sINT L;
- X
- X melde("ycctorgb\n");
- X initctable();
- X
- X w=l->iwidth;
- X h=l->iheight;
- X
- X for(y=0;y<h;y++)
- X {
- X pl = l->im + y * l->mwidth;
- X pc1= c1->im + y * c1->mwidth;
- X pc2= c2->im + y * c2->mwidth;
- X
- X for(x=0;x<w;x++)
- X {
- X L = T_L[*pl];
- X red = (L + T_R[*pc2] )>>RGB_BitSh1;
- X green= (L + T_G[*pc1] + T_g[*pc2] )>>RGB_BitSh1;
- X blue = (L + T_B[*pc1] )>>RGB_BitSh1;
- X
- X red = TRIF(red, 0,RGB_Maximum1,0,red, RGB_Maximum1);
- X green = TRIF(green,0,RGB_Maximum1,0,green,RGB_Maximum1);
- X blue = TRIF(blue ,0,RGB_Maximum1,0,blue, RGB_Maximum1);
- X
- X *(pl++ )=RGB_corr[red];
- X *(pc1++)=RGB_corr[green];
- X *(pc2++)=RGB_corr[blue];
- X }
- X }
- X }
- X#undef BitShift
- X
- X
- X
- X
- X
- Xstatic void sharpit(implane *l)
- X {sINT x,y,h,w,mw,akk;
- X uBYTE f1[slen],f2[slen],*old,*akt,*ptr,*work,*help,*optr=0;
- X
- X melde("sharpit\n");
- X
- X if((!l) || (!l->im)) error(E_INTERN);
- X if(l->iwidth > slen) error(E_INTERN);
- X
- X old=f1; akt=f2;
- X h=l->iheight;
- X w=l->iwidth;
- X mw=l->mwidth;
- X
- X for(y=1;y<h-1;y++)
- X {
- X ptr=l->im+ y*mw;
- X optr=ptr-mw;
- X work=akt;
- X
- X *(work++)= *(ptr++);
- X for(x=1;x<w-1;x++)
- X { akk = 5*((sINT)ptr[0])- ((sINT)ptr[1]) - ((sINT)ptr[-1])
- X - ((sINT)ptr[mw]) - ((sINT)ptr[-mw]);
- X NORM(akk);
- X *(work++)=akk;
- X ptr++;
- X }
- X
- X *(work++)= *(ptr++);
- X
- X if(y>1)
- X for(x=0;x<w;x++)
- X optr[x] = old[x];
- X
- X help=old;old=akt;akt=help;
- X
- X }
- X
- X
- X
- X akt=optr+mw;
- X for(x=0;x<w;x++)
- X *(akt++) = *(old++);
- X }
- X
- X
- X
- X
- X
- X
- X
- Xstatic void initmtable(void)
- X {sINT i,h;
- X static sINT init=0;
- X
- X if(init) return;
- X
- X init=1;
- X
- X initcorr();
- X
- X for(i=0;i<256;i++)
- X { h = (i * RGB_F_LL)>>RGB_BitSh1;
- X h = TRIF(h,0,RGB_Maximum1,0,h,RGB_Maximum1);
- X T_L[i]=RGB_corr[h];
- X }
- X
- X }
- X
- X
- Xstatic void monocorr(implane *l)
- X {dim x,y,w,h;
- X uBYTE *ptr;
- X
- X melde("monocorr\n");
- X initmtable();
- X
- X w=l->iwidth;
- X h=l->iheight;
- X
- X for(y=0;y<h;y++)
- X {
- X ptr= l->im + y * l->mwidth;
- X for(x=0;x<w;x++,ptr++)
- X { *ptr = T_L[*ptr];
- X }
- X }
- X }
- X
- X
- X
- X
- X
- X
- X
- Xvoid colconvert(sizeinfo *si,implane *l,implane *c1,implane *c2)
- X
- X#define w (si->rdhlen)
- X#define h (si->rdvlen)
- X
- X {
- X melde("colconvert\n");
- X
- X if((!l ) || ( l->iwidth != w ) || ( l->iheight != h) || (! l->im)) error(E_INTERN);
- X
- X if(!monochrome)
- X {
- X if((!c1) || (c1->iwidth != w ) || (c1->iheight != h) || (!c1->im)) error(E_INTERN);
- X if((!c2) || (c2->iwidth != w ) || (c2->iheight != h) || (!c2->im)) error(E_INTERN);
- X }
- X
- X if (do_crop) cropit(si,l,c1,c2);
- X else shrink(si,l,c1,c2);
- X if (do_sharp) sharpit(l);
- X
- X switch (outfor)
- X {
- X /* RGB-Conversion */
- X case O_PS:
- X case O_EPS:
- X case O_PPM: ycctorgb(l,c1,c2);
- X break;
- X
- X /* Grayscale Conversion */
- X case O_PSG:
- X case O_EPSG:
- X case O_PSD:
- X case O_EPSD:
- X case O_PGM: monocorr(l);
- X break;
- X
- X /* No Conversion */
- X case O_YCC:
- X break;
- X
- X default: error(E_INTERN);
- X }
- X#undef w
- X#undef h
- X }
- X
- X
- X
- END_OF_FILE
- if test 4566 -ne `wc -c <'hpcdtoppm.0.5.pl1/color.c'`; then
- echo shar: \"'hpcdtoppm.0.5.pl1/color.c'\" unpacked with wrong size!
- fi
- # end of 'hpcdtoppm.0.5.pl1/color.c'
- fi
- if test -f 'hpcdtoppm.0.5.pl1/config.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'hpcdtoppm.0.5.pl1/config.h'\"
- else
- echo shar: Extracting \"'hpcdtoppm.0.5.pl1/config.h'\" \(3735 characters\)
- sed "s/^X//" >'hpcdtoppm.0.5.pl1/config.h' <<'END_OF_FILE'
- X/* hpcdtoppm (Hadmut's pcdtoppm) v0.5pl1
- X* Copyright (c) 1992, 1993 by Hadmut Danisch (danisch@ira.uka.de).
- X* Permission to use and distribute this software and its
- X* documentation for noncommercial use and without fee is hereby granted,
- X* provided that the above copyright notice appear in all copies and that
- X* both that copyright notice and this permission notice appear in
- X* supporting documentation. It is not allowed to sell this software in
- X* any way. This software is not public domain.
- X*/
- X
- X
- X
- X/* define OWN_WRITE either here or by compiler-option if you don't want to use
- X the pbmplus-routines for writing */
- X/* #define OWN_WRITE */
- X
- X
- X
- X/* define DEBUG for some debugging informations */
- X/* #define DEBUG */
- X
- X
- X/* define LONG_HELP or SHORT_HELP, if you want to have an options
- X list if parameters are bad */
- X#define LONG_HELP
- X
- X
- X/* define DO_DECL_EXT for external declaration of system and library calls */
- X#define DO_DECL_EXT
- X
- X
- X/* define FASTHUFF for faster Huffman decoding with tables.
- X** this makes a little speedup, but needs about 768 KByte memory
- X*/
- X#define FASTHUFF
- X
- X
- X
- X#ifdef OWN_WRITE
- X/* If the own routines are used, this is the size of the buffer in bytes.
- X You can shrink if needed. */
- X#define own_BUsize 50000
- X
- X/* The header for the ppm-files */
- X#define PPM_Header "P6\n%d %d\n255\n"
- X#define PGM_Header "P5\n%d %d\n255\n"
- X
- X
- X#endif
- X
- X
- X
- X/* fopen Parameters, for some systems (MS-DOS :-( ) you need "wb" and "rb" */
- X#define W_OP "w"
- X#define R_OP "r"
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X/* if you can't write to stdout in binary mode, you have to fdopen
- X a FILE * in binary mode to stdout. This is important for system,
- X where W_OP is something other than "w". Please define the
- X Macro USE_FDOPEN in this case and check the instructions, where this
- X macro is used.
- X*/
- X
- X/* #define USE_FDOPEN */
- X
- X
- X
- X
- X
- X
- X
- X
- X
- X/** Error detection **/
- X
- X#define error(x) eerror(x,__FILE__,__LINE__)
- X
- X
- X
- X/*
- X** Data Types
- X** Important: sBYTE must be a signed byte type !
- X** If your compiler doesn't understand "signed", remove it.
- X*/
- X
- X#ifndef sBYTE
- Xtypedef signed char sBYTE;
- X#endif
- X
- Xtypedef unsigned char uBYTE;
- X
- X/* signed and unsigned 32-bit-integers
- XsINT and uINT must at least have 32 bit. If you
- Xdon't have 32-bit-integers, take 64-bit and
- Xdefine the macro U_TOO_LONG !!!
- X
- XuINT and sINT must be suitable to the printf/scanf-format %d
- Xand %u and to the systemcalls as fread etc.
- X
- X*/
- X
- X#define uINT unsigned int
- X#define sINT int
- X/* #define U_TOO_LONG */
- X
- X
- X
- X
- X
- X
- Xtypedef uINT dim;
- Xtypedef sINT sdim;
- X
- X
- X
- X
- X/* Floating point data type and string for sscanf */
- X#define FLTPT double
- X#define SSFLTPT "%lf"
- X
- X
- X
- X
- X
- X
- X
- X/* Default taken when no size parameter given,
- X** C_DEFAULT depends on your taste and video-hardware,
- X*/
- X
- X#define S_DEFAULT S_Base16
- X#define O_DEFAULT O_PPM
- X#define C_DEFAULT C_LINEAR
- X#define T_DEFAULT T_AUTO
- X
- X
- X/* Background for contact sheet */
- X#define CONTLUM neutrLum
- X#define CONTCH1 neutrCh1
- X#define CONTCH2 neutrCh2
- X
- X
- X
- X
- X/* Maximum Black value of frame for cutting of the
- X** frame. If MAX_BLACK is n, a frame is detected, when
- X** all Luma values are within [ 0 .. (n-1) ]
- X*/
- X#define MAX_BLACK 1
- X
- X/* Default Postscript paper size
- X** (German DIN A 4 )
- X*/
- X#define DEF_PAPER_LEFT 50.0
- X#define DEF_PAPER_BOTTOM 50.0
- X#define DEF_PAPER_WIDTH 500.0
- X#define DEF_PAPER_HEIGHT 750.0
- X#define DEF_DPI 300.0
- X
- X
- X
- X/* External Declarations */
- X#ifdef DO_DECL_EXT
- X
- Xextern void *malloc(unsigned);
- Xextern int sscanf(char *,char *,...);
- X
- Xextern int fprintf(FILE *,char *,...);
- Xextern int fclose(FILE *);
- Xextern int fseek(FILE *,long,int);
- Xextern int fread(void *,int,int,FILE *);
- Xextern int fwrite(void *,int,int,FILE *);
- Xextern int fputs(char *,FILE *);
- Xextern int fputc(char ,FILE *);
- Xextern int fflush(FILE *);
- X
- X#endif
- X
- X
- X
- X
- X
- X
- X
- END_OF_FILE
- if test 3735 -ne `wc -c <'hpcdtoppm.0.5.pl1/config.h'`; then
- echo shar: \"'hpcdtoppm.0.5.pl1/config.h'\" unpacked with wrong size!
- fi
- # end of 'hpcdtoppm.0.5.pl1/config.h'
- fi
- if test -f 'hpcdtoppm.0.5.pl1/hpcdtoppm.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'hpcdtoppm.0.5.pl1/hpcdtoppm.h'\"
- else
- echo shar: Extracting \"'hpcdtoppm.0.5.pl1/hpcdtoppm.h'\" \(4682 characters\)
- sed "s/^X//" >'hpcdtoppm.0.5.pl1/hpcdtoppm.h' <<'END_OF_FILE'
- X/* hpcdtoppm (Hadmut's pcdtoppm) v0.5pl1
- X* Copyright (c) 1992, 1993 by Hadmut Danisch (danisch@ira.uka.de).
- X* Permission to use and distribute this software and its
- X* documentation for noncommercial use and without fee is hereby granted,
- X* provided that the above copyright notice appear in all copies and that
- X* both that copyright notice and this permission notice appear in
- X* supporting documentation. It is not allowed to sell this software in
- X* any way. This software is not public domain.
- X*/
- X
- X
- X#include <stdio.h>
- X#include <string.h>
- X#include <malloc.h>
- X#include <sys/types.h>
- X#include <ctype.h>
- X#include "config.h"
- X
- X
- X
- X
- X
- X
- X
- X
- X/* Format definitions */
- X
- X#define BaseW ((dim)768)
- X#define BaseH ((dim)512)
- X
- X#define SECSIZE 0x800
- X
- X#define SeHead 2
- X#define L_Head (1+SeHead)
- X
- X#define SeBase16 18
- X#define L_Base16 (1+SeBase16)
- X
- X#define SeBase4 72
- X#define L_Base4 (1+SeBase4)
- X
- X#define SeBase 288
- X#define L_Base (1+SeBase)
- X
- X
- X#define neutrLum 128
- X#define neutrCh1 156
- X#define neutrCh2 137
- X
- X
- X
- X
- X
- X
- X
- X/* Structures and definitions */
- Xstruct _implane
- X {dim mwidth,mheight,
- X iwidth,iheight;
- X uBYTE *im,*mp;
- X };
- Xtypedef struct _implane implane;
- X
- X#define nullplane ((implane *) 0)
- X
- X
- X
- X
- X
- Xstruct _sizeinfo
- X {dim w,h; /* Image Resolution */
- X dim rdhoff,rdhlen, rdvoff, rdvlen; /* Size of Image in Memory */
- X dim imhoff,imhlen, imvoff, imvlen; /* Real Size of Image */
- X };
- Xtypedef struct _sizeinfo sizeinfo;
- X
- X
- X
- X
- X
- X
- Xenum TURNS { T_UNSPEC,T_NONE,T_RIGHT,T_LEFT,T_HEAD,T_AUTO };
- Xenum SIZES { S_UNSPEC,S_Base16,S_Base4,S_Base,S_4Base,S_16Base,S_Over,S_Contact };
- Xenum OUTFOR { O_UNSPEC,O_PPM,O_PGM,O_YCC,O_PS,O_EPS,O_PSG,O_EPSG,O_PSD,O_EPSD };
- Xenum CORR { C_UNSPEC,C_LINEAR,C_DARK,C_BRIGHT };
- X
- Xenum ERRORS { E_NONE,E_READ,E_WRITE,E_INTERN,E_ARG,E_OPT,E_MEM,E_HUFF,
- X E_SEQ,E_SEQ1,E_SEQ2,E_SEQ3,E_SEQ4,E_SEQ5,E_SEQ6,E_SEQ7,E_POS,E_IMP,E_OVSKIP,
- X E_TAUTO,E_TCANT,E_SUBR,E_PRPAR,E_CONFIG };
- X
- X
- X
- X
- X
- X/**** Macros ****/
- X
- X
- X
- X#ifdef DEBUG
- X#define RPRINT {fprintf(stderr,"R-Position %x\n",bufpos);}
- X#else
- X#define RPRINT
- X#endif
- X
- X#define melde(x) {if (do_melde) fprintf(stderr,x);}
- X
- X
- X#define READBUF READ(sbuffer,sizeof(sbuffer))
- X#define EREADBUF {if(READBUF < 1) error(E_READ);}
- X
- X#define SKIP(p) { if (SKIPn(p)) error(E_READ);}
- X#define SKIPr(p) { if (SKIPn(p)) return(E_READ);}
- X
- X
- X#define TRIF(x,u,o,a,b,c) ((x)<(u)? (a) : ( (x)>(o)?(c):(b) ))
- X#define xNORM(x) x=TRIF(x,0,255,0,x,255)
- X#define NORM(x) { if(x<0) x=0; else if (x>255) x=255;}
- X
- X#ifndef MIN
- X#define MIN(a,b) (((a) < (b)) ? (a) : (b))
- X#endif
- X
- X
- X
- X
- X
- X
- X
- X
- X/* main.c */
- Xextern void close_all(void);
- X
- Xextern char *ppmname,*pcdname;
- Xextern sINT do_diff,do_info,do_sharp,do_overskip,monochrome;
- Xextern sINT do_melde,do_rep,do_crop;
- Xextern sINT flvert,flhori;
- Xextern uBYTE sbuffer[SECSIZE];
- Xextern enum TURNS turn;
- Xextern enum SIZES size;
- Xextern enum OUTFOR outfor;
- Xextern enum CORR corrmode;
- X
- Xextern void SEEK(int);
- Xextern int SKIPn(int);
- Xextern int READ(uBYTE *,int);
- Xextern sINT bufpos;
- X
- X
- X
- X
- X/* error.c */
- Xextern void eerror(enum ERRORS,char *, int);
- X
- X
- X/* color.c */
- Xextern void colconvert(sizeinfo *,implane *,implane *,implane *);
- X
- X/* tools.c */
- Xextern void clearimpl(implane *,sINT);
- Xextern void halve(implane *);
- Xextern void interpolate(implane *);
- Xextern sINT Skip4Base(void);
- Xextern void planealloc(implane *,dim,dim);
- Xextern void pastein(implane *,dim,dim,dim,dim,implane *, enum TURNS);
- Xextern void cropit(sizeinfo *,implane *,implane *,implane *);
- Xextern void shrink(sizeinfo *,implane *,implane *,implane *);
- Xextern void typecheck(void);
- X
- X
- X/* format.c */
- Xextern void readhqt(sINT);
- Xextern void decode(sizeinfo *,int,implane *,implane *,implane *,sINT);
- Xextern enum ERRORS readplain(sizeinfo *,int,implane *,implane *,implane *);
- X
- X
- X
- X
- X
- X/* Type definitions for output format drives, used in output.c and the drivers */
- X
- Xtypedef void (OUT1PL)(FILE *,dim,dim, uBYTE *,sdim,sdim);
- Xtypedef void (OUT3PL)(FILE *,dim,dim, uBYTE *,sdim,sdim, uBYTE *,sdim,sdim, uBYTE *,sdim,sdim);
- X
- X/* output.c */
- Xextern void writepicture(FILE *,sizeinfo *,implane *,implane *,implane *,enum TURNS);
- Xextern void druckeid(void);
- X
- X
- X/* ppm.c */
- Xextern OUT3PL write_ppm;
- Xextern OUT1PL write_pgm;
- X
- X/* postscr.c */
- Xextern OUT3PL write_epsrgb,write_psrgb;
- Xextern OUT1PL write_epsgrey,write_psgrey,write_epsdith,write_psdith;
- X
- Xextern FLTPT PAPER_LEFT,PAPER_BOTTOM,PAPER_WIDTH,PAPER_HEIGHT,PRINTER_XDPI,PRINTER_YDPI,PRINTER_FAK;
- Xextern sINT PSIZE_SET,DPI_SET,FAK_SET;
- X
- END_OF_FILE
- if test 4682 -ne `wc -c <'hpcdtoppm.0.5.pl1/hpcdtoppm.h'`; then
- echo shar: \"'hpcdtoppm.0.5.pl1/hpcdtoppm.h'\" unpacked with wrong size!
- fi
- # end of 'hpcdtoppm.0.5.pl1/hpcdtoppm.h'
- fi
- if test -f 'hpcdtoppm.0.5.pl1/ppm.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'hpcdtoppm.0.5.pl1/ppm.c'\"
- else
- echo shar: Extracting \"'hpcdtoppm.0.5.pl1/ppm.c'\" \(3050 characters\)
- sed "s/^X//" >'hpcdtoppm.0.5.pl1/ppm.c' <<'END_OF_FILE'
- X/* hpcdtoppm (Hadmut's pcdtoppm) v0.5pl1
- X* Copyright (c) 1992, 1993 by Hadmut Danisch (danisch@ira.uka.de).
- X* Permission to use and distribute this software and its
- X* documentation for noncommercial use and without fee is hereby granted,
- X* provided that the above copyright notice appear in all copies and that
- X* both that copyright notice and this permission notice appear in
- X* supporting documentation. It is not allowed to sell this software in
- X* any way. This software is not public domain.
- X*/
- X
- X#include "hpcdtoppm.h"
- X
- X
- X
- X
- X#ifdef OWN_WRITE
- X
- X
- Xstatic uBYTE BUF[own_BUsize];
- X#define BUinit {BUcount=0;BUptr=BUF;}
- X
- X#define BUrgb_flush {fwrite(BUF,BUcount*3,1,fout);BUinit; }
- X#define BUrgb_write(r,g,b) {if(BUcount>=own_BUsize/3) BUrgb_flush; *BUptr++ = r ; *BUptr++ = g ; *BUptr++ = b ; BUcount++;}
- X
- X#define BUgreyflush {fwrite(BUF,BUcount,1,fout);BUinit; }
- X#define BUgreywrite(g) {if(BUcount>=own_BUsize) BUgreyflush; *BUptr++ = g ; BUcount++;}
- X
- X
- X
- X
- X
- X
- X
- Xvoid write_ppm(FILE *fout,dim w,dim h,
- X uBYTE *rptr,sdim rzeil,sdim rpix,
- X uBYTE *gptr,sdim gzeil,sdim gpix,
- X uBYTE *bptr,sdim bzeil,sdim bpix)
- X {register uBYTE *pr,*pg,*pb;
- X dim x,y;
- X static uBYTE *BUptr;
- X sINT BUcount;
- X
- X fprintf(fout,PPM_Header,w,h);
- X BUinit;
- X for(y=0;y<h;y++)
- X {
- X pr= rptr; rptr+=rzeil;
- X pg= gptr; gptr+=gzeil;
- X pb= bptr; bptr+=bzeil;
- X for(x=0;x<w;x++)
- X {BUrgb_write(*pr,*pg,*pb);
- X pr+=rpix; pg+=gpix; pb+=bpix;
- X }
- X }
- X BUrgb_flush;
- X
- X }
- X
- X
- X
- X
- X
- X
- Xvoid write_pgm(FILE *fout,dim w,dim h, uBYTE *ptr,sdim zeil,sdim pix)
- X {register uBYTE *p;
- X dim x,y;
- X static uBYTE *BUptr;
- X sINT BUcount;
- X
- X
- X fprintf(fout,PGM_Header,w,h);
- X BUinit;
- X for(y=0;y<h;y++)
- X {
- X p= ptr; ptr+=zeil;
- X
- X for(x=0;x<w;x++)
- X {BUgreywrite(*p);
- X p+=pix;
- X }
- X }
- X BUgreyflush;
- X }
- X
- X
- X#else
- X#include "ppm.h"
- X
- Xvoid write_ppm(FILE *fout,dim w,dim h,
- X uBYTE *rptr,sdim rzeil,sdim rpix,
- X uBYTE *gptr,sdim gzeil,sdim gpix,
- X uBYTE *bptr,sdim bzeil,sdim bpix)
- X {register uBYTE *pr,*pg,*pb;
- X dim x,y;
- X pixel *pixrow;
- X register pixel* pP;
- X
- X
- X ppm_writeppminit(fout,w,h,(pixval) 255, 0);
- X pixrow = ppm_allocrow( w );
- X for(y=0;y<h;y++)
- X {
- X pr= rptr; rptr+=rzeil;
- X pg= gptr; gptr+=gzeil;
- X pb= bptr; bptr+=bzeil;
- X
- X for(pP= pixrow,x=0;x<w;x++)
- X {
- X PPM_ASSIGN(*pP,((sINT)*pr),((sINT)*pg),((sINT)*pb));
- X pP++; pr+=rpix; pg+=gpix; pb+=bpix;
- X }
- X ppm_writeppmrow( fout, pixrow, w, (pixval) 255, 0 );
- X
- X }
- X pm_close(fout);
- X
- X }
- X
- Xvoid write_pgm(FILE *fout,dim w,dim h, uBYTE *ptr,sdim zeil,sdim pix)
- X {register uBYTE *p;
- X dim x,y;
- X gray *grayrow;
- X register gray* pP;
- X
- X
- X pgm_writepgminit(fout,w,h,(pixval) 255, 0);
- X grayrow = pgm_allocrow( w );
- X for(y=0;y<h;y++)
- X {
- X p= ptr; ptr+=zeil;
- X
- X for(pP= grayrow,x=0;x<w;x++)
- X {
- X *pP= ((gray)*p);
- X pP++; p+=pix;
- X }
- X pgm_writepgmrow( fout, grayrow, w, (pixval) 255, 0 );
- X
- X }
- X pm_close(fout);
- X
- X }
- X
- X
- X
- X
- X#endif
- X
- X
- X
- END_OF_FILE
- if test 3050 -ne `wc -c <'hpcdtoppm.0.5.pl1/ppm.c'`; then
- echo shar: \"'hpcdtoppm.0.5.pl1/ppm.c'\" unpacked with wrong size!
- fi
- # end of 'hpcdtoppm.0.5.pl1/ppm.c'
- fi
- echo shar: End of archive 3 \(of 3\).
- cp /dev/null ark3isdone
- MISSING=""
- for I in 1 2 3 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 3 archives.
- rm -f ark[1-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-