home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume43
/
hpcdtoppm
/
part02
< prev
next >
Wrap
Internet Message Format
|
1994-06-10
|
61KB
From: danisch@ira.uka.de (Hadmut Danisch)
Newsgroups: comp.sources.misc
Subject: v43i040: hpcdtoppm - convert Photo-CD file into portable pixmap, v0.6, Part02/03
Date: 10 Jun 1994 11:19:36 -0500
Organization: Sterling Software
Sender: kent@sparky.sterling.com
Approved: kent@sparky.sterling.com
Message-ID: <2ta3qo$fc2@sparky.sterling.com>
X-Md4-Signature: 17382c35361155d8c7c1f08313c8207e
Submitted-by: danisch@ira.uka.de (Hadmut Danisch)
Posting-number: Volume 43, Issue 40
Archive-name: hpcdtoppm/part02
Environment: Photo-CD
Supersedes: hpcdtoppm: Volume 39, Issue 2-4
#! /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.6/const.c hpcdtoppm.0.6/error.c
# hpcdtoppm.0.6/format.c hpcdtoppm.0.6/postscr.c hpcdtoppm.0.6/ppm.c
# Wrapped by kent@sparky on Fri Jun 10 11:08:32 1994
PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
echo If this archive is complete, you will see the following message:
echo ' "shar: End of archive 2 (of 3)."'
if test -f 'hpcdtoppm.0.6/const.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'hpcdtoppm.0.6/const.c'\"
else
echo shar: Extracting \"'hpcdtoppm.0.6/const.c'\" \(14364 characters\)
sed "s/^X//" >'hpcdtoppm.0.6/const.c' <<'END_OF_FILE'
X/* hpcdtoppm (Hadmut's pcdtoppm) v0.6
X* Copyright (c) 1992, 1993, 1994 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
XsINT RGB_BitSh1=8;
XsINT RGB_Maximum1=1023;
X
X
XsINT RGB_F_LL=1391;
XsINT RGB_F_C1=2271;
XsINT RGB_O_C1=-353784;
XsINT RGB_F_C2=1865;
XsINT RGB_O_C2=-255023;
XsINT RGB_F_G1=-441;
XsINT RGB_F_G2=-949;
XsINT RGB_O_G =199313;
X
X
XuBYTE RGB_corr0[]={
X 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
X 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,
X 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11,
X 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15,
X 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, 19, 19, 19, 19,
X 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 23, 23, 23, 23,
X 24, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, 27, 27, 27, 27,
X 28, 28, 28, 28, 29, 29, 29, 29, 30, 30, 30, 30, 31, 31, 31, 31,
X 32, 32, 32, 32, 33, 33, 33, 33, 34, 34, 34, 34, 35, 35, 35, 35,
X 36, 36, 36, 36, 37, 37, 37, 37, 38, 38, 38, 38, 39, 39, 39, 39,
X 40, 40, 40, 40, 41, 41, 41, 41, 42, 42, 42, 42, 43, 43, 43, 43,
X 44, 44, 44, 44, 45, 45, 45, 45, 46, 46, 46, 46, 47, 47, 47, 47,
X 48, 48, 48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51,
X 52, 52, 52, 52, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 55, 55,
X 56, 56, 56, 56, 57, 57, 57, 57, 58, 58, 58, 58, 59, 59, 59, 59,
X 60, 60, 60, 60, 61, 61, 61, 61, 62, 62, 62, 62, 63, 63, 63, 63,
X 64, 64, 64, 64, 65, 65, 65, 65, 66, 66, 66, 66, 67, 67, 67, 67,
X 68, 68, 68, 68, 69, 69, 69, 69, 70, 70, 70, 70, 71, 71, 71, 71,
X 72, 72, 72, 72, 73, 73, 73, 73, 74, 74, 74, 74, 75, 75, 75, 75,
X 76, 76, 76, 76, 77, 77, 77, 77, 78, 78, 78, 78, 79, 79, 79, 79,
X 80, 80, 80, 80, 81, 81, 81, 81, 82, 82, 82, 82, 83, 83, 83, 83,
X 84, 84, 84, 84, 85, 85, 85, 85, 86, 86, 86, 86, 87, 87, 87, 87,
X 88, 88, 88, 88, 89, 89, 89, 89, 90, 90, 90, 90, 91, 91, 91, 91,
X 92, 92, 92, 92, 93, 93, 93, 93, 94, 94, 94, 94, 95, 95, 95, 95,
X 96, 96, 96, 96, 97, 97, 97, 97, 98, 98, 98, 98, 99, 99, 99, 99,
X100,100,100,100,101,101,101,101,102,102,102,102,103,103,103,103,
X104,104,104,104,105,105,105,105,106,106,106,106,107,107,107,107,
X108,108,108,108,109,109,109,109,110,110,110,110,111,111,111,111,
X112,112,112,112,113,113,113,113,114,114,114,114,115,115,115,115,
X116,116,116,116,117,117,117,117,118,118,118,118,119,119,119,119,
X120,120,120,120,121,121,121,121,122,122,122,122,123,123,123,123,
X124,124,124,124,125,125,125,125,126,126,126,126,127,127,127,127,
X128,128,128,128,129,129,129,129,130,130,130,130,131,131,131,131,
X132,132,132,132,133,133,133,133,134,134,134,134,135,135,135,135,
X136,136,136,136,137,137,137,137,138,138,138,138,139,139,139,139,
X140,140,140,140,141,141,141,141,142,142,142,142,143,143,143,143,
X144,144,144,144,145,145,145,145,146,146,146,146,147,147,147,147,
X148,148,148,148,149,149,149,149,150,150,150,150,151,151,151,151,
X152,152,152,152,153,153,153,153,154,154,154,154,155,155,155,155,
X156,156,156,156,157,157,157,157,158,158,158,158,159,159,159,159,
X160,160,160,160,161,161,161,161,162,162,162,162,163,163,163,163,
X164,164,164,164,165,165,165,165,166,166,166,166,167,167,167,167,
X168,168,168,168,169,169,169,169,170,170,170,170,171,171,171,171,
X172,172,172,172,173,173,173,173,174,174,174,174,175,175,175,175,
X176,176,176,176,177,177,177,177,178,178,178,178,179,179,179,179,
X180,180,180,180,181,181,181,181,182,182,182,182,183,183,183,183,
X184,184,184,184,185,185,185,185,186,186,186,186,187,187,187,187,
X188,188,188,188,189,189,189,189,190,190,190,190,191,191,191,191,
X192,192,192,192,193,193,193,193,194,194,194,194,195,195,195,195,
X196,196,196,196,197,197,197,197,198,198,198,198,199,199,199,199,
X200,200,200,200,201,201,201,201,202,202,202,202,203,203,203,203,
X204,204,204,204,205,205,205,205,206,206,206,206,207,207,207,207,
X208,208,208,208,209,209,209,209,210,210,210,210,211,211,211,211,
X212,212,212,212,213,213,213,213,214,214,214,214,215,215,215,215,
X216,216,216,216,217,217,217,217,218,218,218,218,219,219,219,219,
X220,220,220,220,221,221,221,221,222,222,222,222,223,223,223,223,
X224,224,224,224,225,225,225,225,226,226,226,226,227,227,227,227,
X228,228,228,228,229,229,229,229,230,230,230,230,231,231,231,231,
X232,232,232,232,233,233,233,233,234,234,234,234,235,235,235,235,
X236,236,236,236,237,237,237,237,238,238,238,238,239,239,239,239,
X240,240,240,240,241,241,241,241,242,242,242,242,243,243,243,243,
X244,244,244,244,245,245,245,245,246,246,246,246,247,247,247,247,
X248,248,248,248,249,249,249,249,250,250,250,250,251,251,251,251,
X252,252,252,252,253,253,253,253,254,254,254,254,255,255,255,255
X};
X
X
XuBYTE RGB_corr1[]={
X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
X 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
X 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
X 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
X 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
X 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5,
X 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6,
X 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7,
X 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8,
X 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
X 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11,
X 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12,
X 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14,
X 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16,
X 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17,
X 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,
X 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21,
X 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24,
X 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26,
X 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28,
X 28, 29, 29, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 31, 31,
X 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33,
X 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 36, 36, 36, 36,
X 36, 36, 37, 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, 39, 39, 39,
X 39, 39, 39, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 42, 42,
X 42, 42, 42, 43, 43, 43, 43, 43, 44, 44, 44, 44, 44, 45, 45, 45,
X 45, 45, 45, 46, 46, 46, 46, 46, 47, 47, 47, 47, 47, 48, 48, 48,
X 48, 49, 49, 49, 49, 49, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51,
X 52, 52, 52, 52, 52, 53, 53, 53, 53, 54, 54, 54, 54, 54, 55, 55,
X 55, 55, 55, 56, 56, 56, 56, 57, 57, 57, 57, 57, 58, 58, 58, 58,
X 59, 59, 59, 59, 60, 60, 60, 60, 60, 61, 61, 61, 61, 62, 62, 62,
X 62, 63, 63, 63, 63, 63, 64, 64, 64, 64, 65, 65, 65, 65, 66, 66,
X 66, 66, 67, 67, 67, 67, 68, 68, 68, 68, 69, 69, 69, 69, 69, 70,
X 70, 70, 70, 71, 71, 71, 71, 72, 72, 72, 73, 73, 73, 73, 74, 74,
X 74, 74, 75, 75, 75, 75, 76, 76, 76, 76, 77, 77, 77, 77, 78, 78,
X 78, 78, 79, 79, 79, 80, 80, 80, 80, 81, 81, 81, 81, 82, 82, 82,
X 83, 83, 83, 83, 84, 84, 84, 84, 85, 85, 85, 86, 86, 86, 86, 87,
X 87, 87, 87, 88, 88, 88, 89, 89, 89, 89, 90, 90, 90, 91, 91, 91,
X 91, 92, 92, 92, 93, 93, 93, 94, 94, 94, 94, 95, 95, 95, 96, 96,
X 96, 96, 97, 97, 97, 98, 98, 98, 99, 99, 99, 99,100,100,100,101,
X101,101,102,102,102,102,103,103,103,104,104,104,105,105,105,106,
X106,106,107,107,107,107,108,108,108,109,109,109,110,110,110,111,
X111,111,112,112,112,113,113,113,114,114,114,114,115,115,115,116,
X116,116,117,117,117,118,118,118,119,119,119,120,120,120,121,121,
X121,122,122,122,123,123,123,124,124,124,125,125,126,126,126,127,
X127,127,128,128,128,129,129,129,130,130,130,131,131,131,132,132,
X132,133,133,134,134,134,135,135,135,136,136,136,137,137,137,138,
X138,139,139,139,140,140,140,141,141,141,142,142,143,143,143,144,
X144,144,145,145,146,146,146,147,147,147,148,148,149,149,149,150,
X150,150,151,151,152,152,152,153,153,153,154,154,155,155,155,156,
X156,157,157,157,158,158,158,159,159,160,160,160,161,161,162,162,
X162,163,163,164,164,164,165,165,166,166,166,167,167,168,168,168,
X169,169,170,170,170,171,171,172,172,172,173,173,174,174,174,175,
X175,176,176,177,177,177,178,178,179,179,179,180,180,181,181,182,
X182,182,183,183,184,184,184,185,185,186,186,187,187,187,188,188,
X189,189,190,190,190,191,191,192,192,193,193,193,194,194,195,195,
X196,196,197,197,197,198,198,199,199,200,200,200,201,201,202,202,
X203,203,204,204,204,205,205,206,206,207,207,208,208,209,209,209,
X210,210,211,211,212,212,213,213,214,214,214,215,215,216,216,217,
X217,218,218,219,219,220,220,220,221,221,222,222,223,223,224,224,
X225,225,226,226,227,227,228,228,228,229,229,230,230,231,231,232,
X232,233,233,234,234,235,235,236,236,237,237,238,238,239,239,240,
X240,241,241,242,242,243,243,244,244,245,245,245,246,246,247,247,
X248,248,249,249,250,250,251,251,252,252,253,253,254,254,255,255
X};
X
X
XuBYTE RGB_corr2[]={
X 0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16,
X 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 32,
X 33, 34, 35, 36, 37, 37, 38, 39, 40, 40, 41, 42, 42, 43, 44, 45,
X 45, 46, 46, 47, 48, 48, 49, 50, 50, 51, 51, 52, 53, 53, 54, 54,
X 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62, 63, 63,
X 64, 64, 65, 65, 66, 66, 66, 67, 67, 68, 68, 69, 69, 70, 70, 71,
X 71, 72, 72, 73, 73, 73, 74, 74, 75, 75, 76, 76, 76, 77, 77, 78,
X 78, 79, 79, 79, 80, 80, 81, 81, 81, 82, 82, 83, 83, 83, 84, 84,
X 85, 85, 85, 86, 86, 86, 87, 87, 88, 88, 88, 89, 89, 89, 90, 90,
X 91, 91, 91, 92, 92, 92, 93, 93, 93, 94, 94, 95, 95, 95, 96, 96,
X 96, 97, 97, 97, 98, 98, 98, 99, 99, 99,100,100,100,101,101,101,
X102,102,102,103,103,103,104,104,104,104,105,105,105,106,106,106,
X107,107,107,108,108,108,109,109,109,109,110,110,110,111,111,111,
X112,112,112,112,113,113,113,114,114,114,114,115,115,115,116,116,
X116,116,117,117,117,118,118,118,118,119,119,119,120,120,120,120,
X121,121,121,121,122,122,122,123,123,123,123,124,124,124,124,125,
X125,125,126,126,126,126,127,127,127,127,128,128,128,128,129,129,
X129,129,130,130,130,130,131,131,131,131,132,132,132,132,133,133,
X133,133,134,134,134,134,135,135,135,135,136,136,136,136,137,137,
X137,137,138,138,138,138,139,139,139,139,140,140,140,140,140,141,
X141,141,141,142,142,142,142,143,143,143,143,143,144,144,144,144,
X145,145,145,145,146,146,146,146,146,147,147,147,147,148,148,148,
X148,148,149,149,149,149,150,150,150,150,150,151,151,151,151,152,
X152,152,152,152,153,153,153,153,153,154,154,154,154,155,155,155,
X155,155,156,156,156,156,156,157,157,157,157,157,158,158,158,158,
X159,159,159,159,159,160,160,160,160,160,161,161,161,161,161,162,
X162,162,162,162,163,163,163,163,163,164,164,164,164,164,165,165,
X165,165,165,166,166,166,166,166,167,167,167,167,167,168,168,168,
X168,168,169,169,169,169,169,170,170,170,170,170,171,171,171,171,
X171,171,172,172,172,172,172,173,173,173,173,173,174,174,174,174,
X174,174,175,175,175,175,175,176,176,176,176,176,177,177,177,177,
X177,177,178,178,178,178,178,179,179,179,179,179,179,180,180,180,
X180,180,181,181,181,181,181,181,182,182,182,182,182,183,183,183,
X183,183,183,184,184,184,184,184,184,185,185,185,185,185,186,186,
X186,186,186,186,187,187,187,187,187,187,188,188,188,188,188,189,
X189,189,189,189,189,190,190,190,190,190,190,191,191,191,191,191,
X191,192,192,192,192,192,192,193,193,193,193,193,193,194,194,194,
X194,194,194,195,195,195,195,195,195,196,196,196,196,196,196,197,
X197,197,197,197,197,198,198,198,198,198,198,199,199,199,199,199,
X199,200,200,200,200,200,200,201,201,201,201,201,201,201,202,202,
X202,202,202,202,203,203,203,203,203,203,204,204,204,204,204,204,
X205,205,205,205,205,205,205,206,206,206,206,206,206,207,207,207,
X207,207,207,207,208,208,208,208,208,208,209,209,209,209,209,209,
X210,210,210,210,210,210,210,211,211,211,211,211,211,211,212,212,
X212,212,212,212,213,213,213,213,213,213,213,214,214,214,214,214,
X214,215,215,215,215,215,215,215,216,216,216,216,216,216,216,217,
X217,217,217,217,217,217,218,218,218,218,218,218,219,219,219,219,
X219,219,219,220,220,220,220,220,220,220,221,221,221,221,221,221,
X221,222,222,222,222,222,222,222,223,223,223,223,223,223,223,224,
X224,224,224,224,224,224,225,225,225,225,225,225,225,226,226,226,
X226,226,226,226,227,227,227,227,227,227,227,228,228,228,228,228,
X228,228,229,229,229,229,229,229,229,230,230,230,230,230,230,230,
X231,231,231,231,231,231,231,231,232,232,232,232,232,232,232,233,
X233,233,233,233,233,233,234,234,234,234,234,234,234,234,235,235,
X235,235,235,235,235,236,236,236,236,236,236,236,237,237,237,237,
X237,237,237,237,238,238,238,238,238,238,238,239,239,239,239,239,
X239,239,239,240,240,240,240,240,240,240,241,241,241,241,241,241,
X241,241,242,242,242,242,242,242,242,243,243,243,243,243,243,243,
X243,244,244,244,244,244,244,244,244,245,245,245,245,245,245,245,
X246,246,246,246,246,246,246,246,247,247,247,247,247,247,247,247,
X248,248,248,248,248,248,248,248,249,249,249,249,249,249,249,249,
X250,250,250,250,250,250,250,250,251,251,251,251,251,251,251,252,
X252,252,252,252,252,252,252,253,253,253,253,253,253,253,253,254,
X254,254,254,254,254,254,254,255,255,255,255,255,255,255,255,255
X};
X
X
XsINT dithtab[]={
X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
X 0, 0, 1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10,
X 11, 12, 13, 14, 15, 15, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26,
X 27, 29, 30, 31, 32, 34, 35, 36, 37, 39, 40, 42, 43, 44, 46, 47,
X 49, 50, 51, 53, 54, 56, 57, 59, 60, 62, 64, 65, 67, 68, 70, 71,
X 73, 75, 76, 78, 80, 81, 83, 85, 86, 88, 90, 91, 93, 95, 96, 98,
X100,102,103,105,107,109,110,112,114,116,117,119,121,123,124,126,
X128,130,131,133,135,137,138,140,142,144,145,147,149,151,152,154,
X156,157,159,161,163,164,166,168,169,171,173,174,176,178,179,181,
X183,184,186,187,189,190,192,194,195,197,198,200,201,203,204,206,
X207,208,210,211,213,214,215,217,218,219,221,222,223,224,226,227,
X228,229,230,231,233,234,235,236,237,238,239,240,241,242,243,243,
X244,245,246,247,248,248,249,250,250,251,252,252,253,253,254,255,
X255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
X255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
X};
X
X
END_OF_FILE
if test 14364 -ne `wc -c <'hpcdtoppm.0.6/const.c'`; then
echo shar: \"'hpcdtoppm.0.6/const.c'\" unpacked with wrong size!
fi
# end of 'hpcdtoppm.0.6/const.c'
fi
if test -f 'hpcdtoppm.0.6/error.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'hpcdtoppm.0.6/error.c'\"
else
echo shar: Extracting \"'hpcdtoppm.0.6/error.c'\" \(9116 characters\)
sed "s/^X//" >'hpcdtoppm.0.6/error.c' <<'END_OF_FILE'
X/* hpcdtoppm (Hadmut's pcdtoppm) v0.6
X* Copyright (c) 1992, 1993, 1994 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#define X(a,b) ((a == b) ? "->" : " ")
X
Xvoid eerror(enum ERRORS e,char *file,int line)
X {
X
X switch(e)
X {case E_NONE: return;
X case E_IMP: fprintf(stderr,"Sorry, Not yet implemented. [%s:%d]\n",file,line); break;
X case E_READ: fprintf(stderr,"Error while reading.\n"); break;
X case E_WRITE: fprintf(stderr,"Error while writing.\n"); break;
X case E_INTERN: fprintf(stderr,"Internal error. [%s:%d]\n",file,line); break;
X case E_ARG: fprintf(stderr,"Error in Arguments !\n\n");
X#ifdef SHORT_HELP
X fprintf(stderr,"Usage: hpcdtoppm [options] pcd-file [ppm-file]\n");
X fprintf(stderr," ( - means stdin )\n");
X fprintf(stderr,"Opts: [ -> = Default ] \n\n");
X fprintf(stderr," [-x] [-s] [-d] [-i] [-m]\n");
X fprintf(stderr," [-crop] [-pos] [-rep] [-vert] [-hori] [-S h v]\n");
X fprintf(stderr," [-n] [-r] [-l] [-h] [-a]\n");
X fprintf(stderr," [-ppm] [-pgm] [-ycc] [-ps] [-eps] [-psg] [-epsg] [-psd] [-epsd]\n");
X fprintf(stderr," [-pl f] [-pb f] [-pw f] [-ph f] [-dpi f] [-fak f]\n");
X fprintf(stderr," [-c0] [-c-] [-c+]\n");
X fprintf(stderr," [-0] [-C d s] [-1] [-2] [-3] [-4] [-5] [-6]\n");
X
X#endif
X#ifdef LONG_HELP
X fprintf(stderr,"Usage: hpcdtoppm [options] pcd-file [ppm-file]\n");
X fprintf(stderr," ( - means stdin )\n");
X fprintf(stderr,"Opts: [ -> = Default ] \n\n");
X
X fprintf(stderr," -x Overskip mode (tries to improve color quality.)\n");
X fprintf(stderr," -s Apply simple sharpness-operator on the Luma-channel.\n");
X fprintf(stderr," -d Show differential picture only.\n");
X fprintf(stderr," -i Give some (buggy) informations from fileheader.\n");
X fprintf(stderr," -m Show the decoding steps to stderr.\n");
X fprintf(stderr," -crop Try to cut off the black frame.\n");
X fprintf(stderr," -pos Print file position of image to stderr.\n");
X fprintf(stderr," -rep Try to jump over defects in the Huffman Code.\n");
X fprintf(stderr," -vert Flip image vert.\n");
X fprintf(stderr," -hori Flip image horiz.\n");
X fprintf(stderr," -S h v Decode subrectangle with hori. and vert. boundaries h,v,\n");
X fprintf(stderr," h,v of the form a-b or a+b, a and b integer or float [0.0...1.0]\n");
X fprintf(stderr,"\n");
X
X fprintf(stderr," %s -n Don't rotate.\n", X(T_DEFAULT,T_NONE));
X fprintf(stderr," %s -r Rotate clockwise for portraits.\n" , X(T_DEFAULT,T_RIGHT));
X fprintf(stderr," %s -l Rotate counter-clockwise for portraits.\n", X(T_DEFAULT,T_LEFT));
X fprintf(stderr," %s -h Rotate twice, turn on head.\n", X(T_DEFAULT,T_HEAD));
X fprintf(stderr," %s -a Try to find out orientation automatically.\n", X(T_DEFAULT,T_AUTO));
X fprintf(stderr,"\n");
X
X fprintf(stderr," %s -ppm output rgb (ppm-format). \n", X(O_DEFAULT,O_PPM));
X fprintf(stderr," %s -pgm output gray (pgm-format). \n", X(O_DEFAULT,O_PGM));
X fprintf(stderr," %s -ycc output ycc (ppm-format). \n", X(O_DEFAULT,O_YCC));
X fprintf(stderr," %s -ps output postscript (rgb). \n", X(O_DEFAULT,O_PS));
X fprintf(stderr," %s -eps output encapsulated postscript (rgb). \n", X(O_DEFAULT,O_EPS));
X fprintf(stderr," %s -psg output postscript (grayscale). \n", X(O_DEFAULT,O_PSG));
X fprintf(stderr," %s -epsg output encapsulated postscript (grayscale). \n", X(O_DEFAULT,O_EPSG));
X fprintf(stderr," %s -psd output postscript (b&w dithered). \n", X(O_DEFAULT,O_PSG));
X fprintf(stderr," %s -epsd output encapsulated postscript (b&w dithered).\n",X(O_DEFAULT,O_EPSG));
X fprintf(stderr," -pl f Postscript paper left position [ Def: %8.3f ]\n",DEF_PAPER_LEFT);
X fprintf(stderr," -pb f Postscript paper bottom position [ Def: %8.3f ]\n",DEF_PAPER_BOTTOM);
X fprintf(stderr," -pw f Postscript paper width [ Def: %8.3f ]\n",DEF_PAPER_WIDTH);
X fprintf(stderr," -ph f Postscript paper height [ Def: %8.3f ]\n",DEF_PAPER_HEIGHT);
X fprintf(stderr," -dpi f Postscript resolution for dith. [ Def: %8.3f ]\n",DEF_DPI);
X fprintf(stderr," -fak f Scaling factor for dith. [ Def: 1.0 ]\n");
X fprintf(stderr,"\n");
X
X fprintf(stderr," %s -c0 don't correct (linear).\n", X(C_DEFAULT,C_LINEAR));
X fprintf(stderr," %s -c- correct darker.\n", X(C_DEFAULT,C_DARK));
X fprintf(stderr," %s -c+ correct brighter.\n", X(C_DEFAULT,C_BRIGHT));
X fprintf(stderr,"\n");
X
X fprintf(stderr," %s -0 Extract thumbnails from Overview file.\n", X(S_DEFAULT,S_Over));
X fprintf(stderr," %s -C d s Extract contact sheet from Overview file, d images width,\n",X(S_DEFAULT,S_Contact));
X fprintf(stderr," with contact sheet orientation s ( one of n l r h).\n");
X fprintf(stderr," %s -1 Extract 128x192 from Image file.\n", X(S_DEFAULT,S_Base16));
X fprintf(stderr," %s -2 Extract 256x384 from Image file.\n", X(S_DEFAULT,S_Base4));
X fprintf(stderr," %s -3 Extract 512x768 from Image file.\n", X(S_DEFAULT,S_Base));
X fprintf(stderr," %s -4 Extract 1024x1536 from Image file.\n", X(S_DEFAULT,S_4Base));
X fprintf(stderr," %s -5 Extract 2048x3072 from Image file.\n", X(S_DEFAULT,S_16Base));
X fprintf(stderr," %s -6 Extract 4096x6144 from Image file and 64Base-Directory.\n", X(S_DEFAULT,S_64Base));
X fprintf(stderr,"\n");
X#endif
X break;
X case E_OPT: fprintf(stderr,"These Options are not allowed together.\n");break;
X case E_MEM: fprintf(stderr,"Not enough memory !\n"); break;
X case E_HUFF: fprintf(stderr,"Error in Huffman-Code-Table\n"); break;
X case E_SEQ: fprintf(stderr,"Error in Huffman-Sequence, try option -rep\n"); break;
X case E_SEQ1: fprintf(stderr,"Error1 in Huffman-Sequence, try option -rep\n"); break;
X case E_SEQ2: fprintf(stderr,"Error2 in Huffman-Sequence, try option -rep\n"); break;
X case E_SEQ3: fprintf(stderr,"Error3 in Huffman-Sequence, try option -rep\n"); break;
X case E_SEQ4: fprintf(stderr,"Error4 in Huffman-Sequence, try option -rep\n"); break;
X case E_SEQ5: fprintf(stderr,"Error5 in Huffman-Sequence, try option -rep\n"); break;
X case E_SEQ6: fprintf(stderr,"Error6 in Huffman-Sequence, try option -rep\n"); break;
X case E_SEQ7: fprintf(stderr,"Error7 in Huffman-Sequence, try option -rep\n"); break;
X case E_POS: fprintf(stderr,"Error in file-position\n"); break;
X case E_OVSKIP: fprintf(stderr,"Can't read this resolution in overskip-mode\n"); break;
X case E_TAUTO: fprintf(stderr,"Can't determine the orientation in overview mode\n");break;
X case E_SUBR: fprintf(stderr,"Error in Subrectangle Parameters\n");break;
X case E_PRPAR: fprintf(stderr,"Bad printing parameters\n");break;
X case E_CONFIG: fprintf(stderr,"Something is wrong with your configuration [see %s:%d]\n",file,line);
X fprintf(stderr,"Edit the config.h and recompile...\n"); break;
X case E_TCANT: fprintf(stderr,"Sorry, can't determine orientation for this file.\n");
X fprintf(stderr,"Please give orientation parameters. \n");break;
X case E_FOPEN: fprintf(stderr,"Can't open file\n"); break;
X default: fprintf(stderr,"Unknown error %d ??? [%s:%d]\n",e,file,line);break;
X }
X close_all();
X exit(9);
X }
X
X
END_OF_FILE
if test 9116 -ne `wc -c <'hpcdtoppm.0.6/error.c'`; then
echo shar: \"'hpcdtoppm.0.6/error.c'\" unpacked with wrong size!
fi
# end of 'hpcdtoppm.0.6/error.c'
fi
if test -f 'hpcdtoppm.0.6/format.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'hpcdtoppm.0.6/format.c'\"
else
echo shar: Extracting \"'hpcdtoppm.0.6/format.c'\" \(18842 characters\)
sed "s/^X//" >'hpcdtoppm.0.6/format.c' <<'END_OF_FILE'
X/* hpcdtoppm (Hadmut's pcdtoppm) v0.6
X* Copyright (c) 1992, 1993, 1994 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
Xstruct pcdquad { uBYTE len,highseq,lowseq,key;};
Xstruct pcdhqt { uBYTE entries; struct pcdquad entry[256];};
Xstruct myhqt { uINT seq,mask,len; uBYTE key; };
X
Xstatic struct myhqt myhuff0[256],myhuff1[256],myhuff2[256];
Xstatic sINT myhufflen0=0,myhufflen1=0,myhufflen2=0;
X
X
X
X
Xstatic void readhqtsub(struct pcdhqt *quelle,struct myhqt *ziel,sINT *anzahl)
X#define E ((uINT) 1)
X {sINT i;
X struct pcdquad *sub;
X struct myhqt *help;
X *anzahl=(quelle->entries)+1;
X
X for(i=0;i<*anzahl;i++)
X {sub = (struct pcdquad *)(((uBYTE *)quelle)+1+i*sizeof(*sub));
X help=ziel+i;
X
X help->seq = (((uINT) sub->highseq) << 24) |(((uINT) sub->lowseq) << 16);
X help->len = ((uINT) sub->len) +1;
X help->key = sub->key;
X
X#ifdef DEBUGhuff
X fprintf(stderr," Anz: %d A1: %08x A2: %08x X:%02x %02x %02x %02x Seq: %08x Laenge: %d %d\n",
X *anzahl,(uINT)sbuffer,(uINT)sub,
X ((uBYTE *)sub)[0],((uBYTE *)sub)[1],((uBYTE *)sub)[2],((uBYTE *)sub)[3],
X help->seq,help->len,sizeof(uBYTE));
X#endif
X
X if(help->len > 16) error(E_HUFF);
X
X help->mask = ~ ( (E << (32-help->len)) -1);
X
X }
X#ifdef DEBUG
X for(i=0;i<*anzahl;i++)
X {help=ziel+i;
X fprintf(stderr,"H: %3d %08lx & %08lx (%2d) = %02x = %5d %8x\n",
X i, help->seq,help->mask,help->len,help->key,(sBYTE)help->key,
X help->seq & (~help->mask));
X }
X#endif
X
X#undef E
X}
X
X
X
X
X
X
X
Xvoid readhqt(sINT n)
X {
X uBYTE *ptr;
X
X melde("readhqt\n");
X EREADBUF;
X ptr = sbuffer;
X
X readhqtsub((struct pcdhqt *)ptr,myhuff0,&myhufflen0);
X
X if(n<2) return;
X ptr+= 1 + 4* myhufflen0;
X readhqtsub((struct pcdhqt *)ptr,myhuff1,&myhufflen1);
X
X if(n<3) return;
X ptr+= 1 + 4* myhufflen1;
X readhqtsub((struct pcdhqt *)ptr,myhuff2,&myhufflen2);
X
X}
X
Xvoid readhqtx(sINT n)
X {
X uBYTE *ptr;
X
X melde("readhqtx\n");
X ptr = sbuffer;
X
X readhqtsub((struct pcdhqt *)ptr,myhuff0,&myhufflen0);
X
X if(n<2) return;
X ptr+= 1 + 4* myhufflen0;
X readhqtsub((struct pcdhqt *)ptr,myhuff1,&myhufflen1);
X
X if(n<3) return;
X ptr+= 1 + 4* myhufflen1;
X readhqtsub((struct pcdhqt *)ptr,myhuff2,&myhufflen2);
X
X}
X
X
X
X
X
X
X
X
X
X#ifdef FASTHUFF
X
Xstatic struct myhqt *HTAB0[0x10000],*HTAB1[0x10000],*HTAB2[0x10000];
X
Xstatic void inithuff(sINT hlen,struct myhqt *ptr,struct myhqt *TAB[])
X {sINT i,n;
X sINT seq,len;
X struct myhqt *help;
X
X for(i=0;i<0x10000;i++) TAB[i]=0;
X
X for(n=0;n<hlen;n++)
X {help=ptr+n;
X seq=(help->seq)>>16;
X len=help->len;
X
X for(i=0;i<(1<<(16-len));i++)
X TAB[seq | i] = help;
X }
X }
X#endif
X
X
X
X
Xstatic char *pn[]={"Luma Channel","Chroma1 Channel","Chroma2 Channel"};
X
X
Xvoid decode(sizeinfo *si,int fak,implane *f,implane *f1,implane *f2,sINT autosync)
X {dim w,h,hoff,hlen,hende,voff,vlen,vende,anfang,ende;
X sINT htlen,sum,do_inform,part;
X uINT sreg,maxwidth;
X uINT inh,n,zeile,segment,ident;
X struct myhqt *hp;
X
X uBYTE *nptr;
X uBYTE *lptr;
X
X#define nextbuf { nptr=sbuffer; if(READBUF<1) { if(!do_rep) error(E_READ); \
X fprintf(stderr,"Read error\n"); \
X return; } }
X#define checkbuf { if (nptr >= sbuffer + sizeof(sbuffer)) nextbuf; }
X
X#ifdef U_TOO_LONG
X#define shiftreg(n) sreg = (sreg<< n ) & 0xffffffff;
X#else
X#define shiftreg(n) sreg<<=n;
X#endif
X
X#define shiftout(n){ shiftreg(n); inh-=n; \
X while (inh<=24) \
X {checkbuf; \
X sreg |= ((uINT)(*(nptr++)))<<(24-inh);\
X inh+=8;\
X }\
X }
X#define issync ((sreg & 0xffffff00) == 0xfffffe00)
X#define brutesync ((sreg & 0x00fff000) == 0x00fff000)
X#define seeksync { while (!brutesync) shiftout(8); while (!issync) shiftout(1);}
X
X#ifdef FASTHUFF
X struct myhqt **HTAB;
X HTAB=0;
X inithuff(myhufflen0,myhuff0,HTAB0);
X inithuff(myhufflen1,myhuff1,HTAB1);
X inithuff(myhufflen2,myhuff2,HTAB2);
X#define SETHUFF0 HTAB=HTAB0;
X#define SETHUFF1 HTAB=HTAB1;
X#define SETHUFF2 HTAB=HTAB2;
X#define FINDHUFF(x) {x=HTAB[sreg>>16];}
X
X#else
X
X sINT i;
X struct myhqt *htptr;
X htptr=0;
X#define SETHUFF0 { htlen=myhufflen0 ; htptr = myhuff0 ; }
X#define SETHUFF1 { htlen=myhufflen1 ; htptr = myhuff1 ; }
X#define SETHUFF2 { htlen=myhufflen2 ; htptr = myhuff2 ; }
X#define FINDHUFF(x) {for(i=0, x=htptr;(i<htlen) && ((sreg & x ->mask)!= x->seq); i++,x++); \
X if(i>=htlen) x=0;}
X#endif
X
X melde("decode\n");
X anfang=ende=0;
X
X if(fak >= 0)
X {w =si->w *fak;
X h =si->h *fak;
X hoff=si->rdhoff*fak; if(hoff & 1 ) error(E_INTERN); /* Must be all even */
X hlen=si->rdhlen*fak; if(hlen & 1 ) error(E_INTERN); hende=hlen+hoff;
X voff=si->rdvoff*fak; if(voff & 1 ) error(E_INTERN);
X vlen=si->rdvlen*fak; if(vlen & 1 ) error(E_INTERN); vende=vlen+voff;
X }
X else
X {fak = -fak;
X w =si->w /fak;
X h =si->h /fak;
X hoff=si->rdhoff/fak; if(hoff & 1 ) error(E_INTERN); /* Must be all even */
X hlen=si->rdhlen/fak; if(hlen & 1 ) error(E_INTERN); hende=hlen+hoff;
X voff=si->rdvoff/fak; if(voff & 1 ) error(E_INTERN);
X vlen=si->rdvlen/fak; if(vlen & 1 ) error(E_INTERN); vende=vlen+voff;
X }
X
X
X if( f && ((! f->im) || ( f->iheight != vlen ) || (f->iwidth != hlen ))) error(E_INTERN);
X if( f1 && ((!f1->im) || (f1->iheight != vlen/2) || (f1->iwidth != hlen/2))) error(E_INTERN);
X if( f2 && ((!f2->im) || (f2->iheight != vlen/2) || (f2->iwidth != hlen/2))) error(E_INTERN);
X
X htlen=sreg=maxwidth=0;
X zeile=0;
X nextbuf;
X inh=32;
X lptr=0;
X part=do_inform=0;
X shiftout(16);
X shiftout(16);
X
X if(autosync) seeksync;
X
X if(!issync)
X { if(!do_rep) error(E_SEQ6);
X else
X {fprintf(stderr,"Image does not start with synchron mark, seeking...\n");
X seeksync;
X do_inform=1;
X }
X }
X
X n=0;
X
X for(;;)
X {
X if (issync)
X {shiftout(24);
X ident=sreg>>16;
X shiftout(16);
X
X zeile=(ident>>1) & 0x1fff;
X segment=ident>>14;
X if(do_inform) {fprintf(stderr,"Synchron mark found Line %d\n",zeile);do_inform=0;}
X#ifdef DEBUG
X fprintf(stderr,"Id %4x Zeile: %6d Seg %3d Pix bisher: %5d Position: %8lx+%5lx=%8x\n",
X ident,zeile,segment,n,bufpos,nptr-sbuffer,bufpos+nptr-sbuffer);
X#endif
X
X
X if(lptr && (n!=maxwidth))
X {if(!do_rep)error(E_SEQ1);
X else fprintf(stderr,"Line %d in %s : wrong length of last line (%d)\n",zeile,pn[part],n);
X }
X n=0;
X
X if(zeile==h) {RPRINT; return; }
X if(zeile >h)
X { if(!do_rep) error(E_SEQ2);
X else
X {fprintf(stderr,"Wrong line number %d, ignoring line\n",zeile);
X seeksync;
X n=maxwidth;
X do_inform=1;
X }
X }
X else switch(segment)
X {
X case 1: if(!do_rep) error(E_SEQ3);
X fprintf(stderr,"Abnormal line tag in %d, interpreting as Luma tag\n",zeile);
X case 0: maxwidth=w;
X if((!f) && autosync) {seeksync; n=maxwidth; break;}
X if(!f) error(E_SEQ7);
X if((zeile<voff) || (zeile >= vende)) {seeksync; n=maxwidth; break;}
X anfang=hoff; ende=hende;
X lptr=f->im + (zeile-voff)*f->mwidth;
X SETHUFF0;
X part=0;
X break;
X
X case 2: maxwidth=w>>1;
X if(!f1) return;
X /*if((!f1) && autosync) {seeksync; break;}*/
X if((zeile<voff) || (zeile >= vende)) {seeksync; n=maxwidth; break;}
X anfang=hoff>>1; ende=hende>>1;
X lptr=f1->im + ((zeile-voff)>>1)*f1->mwidth;
X SETHUFF1;
X part=1;
X break;
X
X case 3: maxwidth=w>>1;
X if(!f2) return;
X /*if((!f2) && autosync) {seeksync; break;}*/
X if((zeile<voff) || (zeile >= vende)) {seeksync; n=maxwidth; break;}
X anfang=hoff>>1; ende=hende>>1;
X lptr=f2->im + ((zeile-voff)>>1)*f2->mwidth;
X SETHUFF2;
X part=2;
X break;
X
X default:error(E_SEQ3);
X }
X }
X else
X {
X if(!lptr) error(E_SEQ6);
X
X if(n>maxwidth)
X {
X#ifdef DEBUG
X fprintf(stderr,"Register: %08lx Pos: %08lx\n",sreg,bufpos+nptr-sbuffer);
X#endif
X if (!do_rep) error(E_SEQ4);
X else { fprintf(stderr,"Missing synchron mark in %s line %d\n",pn[part],zeile);
X seeksync;
X do_inform=1;
X n=maxwidth;
X }
X }
X else
X {FINDHUFF(hp);
X if(!hp)
X { if(!do_rep) error(E_SEQ5);
X fprintf(stderr,"Unable to decode, ignoring rest of line\n");
X seeksync;
X n=maxwidth;
X do_inform=1;
X }
X else
X {if((n>= anfang) && (n<ende))
X {sum=((sINT)(*lptr)) + ((sBYTE)hp->key);
X NORM(sum);
X *(lptr++) = sum;
X }
X
X n++;
X shiftout(hp->len);
X }
X }
X }
X
X }
X
X
X#undef nextbuf
X#undef checkbuf
X#undef shiftout
X#undef issync
X#undef seeksync
X
X }
X
X
X
X/* Decode the 64Base files */
Xvoid decodex(FILE **fp, int tag , struct ic_descr *descr,sizeinfo *si,int fak,implane *f,sINT autosync)
X {dim w,h,hoff,hlen,hende,voff,vlen,vende,anfang,ende;
X sINT htlen,sum,do_inform,part;
X uINT sreg,maxwidth;
X uINT inh,n,pos,zeile,segment,ident,sector,offset,length;
X struct myhqt *hp;
X
X uBYTE *nptr;
X uBYTE *lptr;
X
X int bufcont;
X
X
X
X#define nextbuf { nptr=sbuffer; \
X do\
X {bufcont=fread(sbuffer,1,sizeof(sbuffer),*fp);\
X if(bufcont<1)\
X {if(feof(*fp)) fp++;\
X else if(!do_rep) error(E_READ);\
X else {fprintf(stderr,"Read error\n"); return;}\
X if(!*fp) return; }\
X } while (bufcont<1); }
X
X
X#define checkbuf { if (nptr >= sbuffer + bufcont) nextbuf; }
X
X#ifdef U_TOO_LONG
X#define shiftreg(n) sreg = (sreg<< n ) & 0xffffffff;
X#else
X#define shiftreg(n) sreg<<=n;
X#endif
X
X#define shiftout(n){ shiftreg(n); inh-=n; \
X while (inh<=24) \
X {checkbuf; \
X sreg |= ((uINT)(*(nptr++)))<<(24-inh);\
X inh+=8;\
X }\
X }
X#define issync ((sreg & 0xffffff00) == 0xfffffe00)
X#define brutesync ((sreg & 0x00fff000) == 0x00fff000)
X#define seeksync { while ((!brutesync) && (bufcont>0)) shiftout(8); \
X while ((!issync) && (bufcont>0)) shiftout(1);}
X
X#ifdef FASTHUFF
X struct myhqt **HTAB;
X HTAB=0;
X switch(tag)
X {case 0: inithuff(myhufflen0,myhuff0,HTAB0); break;
X case 1: inithuff(myhufflen1,myhuff1,HTAB1); break;
X case 2: inithuff(myhufflen2,myhuff2,HTAB2); break;
X default: error(E_INTERN);
X }
X#define SETHUFF0 HTAB=HTAB0;
X#define SETHUFF1 HTAB=HTAB1;
X#define SETHUFF2 HTAB=HTAB2;
X#define FINDHUFF(x) {x=HTAB[sreg>>16];}
X
X#else
X
X sINT i;
X struct myhqt *htptr;
X htptr=0;
X#define SETHUFF0 { htlen=myhufflen0 ; htptr = myhuff0 ; }
X#define SETHUFF1 { htlen=myhufflen1 ; htptr = myhuff1 ; }
X#define SETHUFF2 { htlen=myhufflen2 ; htptr = myhuff2 ; }
X#define FINDHUFF(x) {for(i=0, x=htptr;(i<htlen) && ((sreg & x ->mask)!= x->seq); i++,x++); \
X if(i>=htlen) x=0;}
X#endif
X
X
X
X
X
X
X
X melde("decodex\n");
X anfang=ende=0;
X maxwidth=FILE32(descr->length);
X h =FILE16(descr->height);
X offset =FILE16(descr->offset);
X length =FILE32(descr->length);
X
X
X if(fak >= 0)
X {w =si->w *fak;
X h =si->h *fak;
X hoff=si->rdhoff*fak; if(hoff & 1 ) error(E_INTERN);
X hlen=si->rdhlen*fak; if(hlen & 1 ) error(E_INTERN); hende=hlen+hoff;
X voff=si->rdvoff*fak; if(voff & 1 ) error(E_INTERN);
X vlen=si->rdvlen*fak; if(vlen & 1 ) error(E_INTERN); vende=vlen+voff;
X }
X else
X {fak = -fak;
X w =si->w /fak;
X h =si->h /fak;
X hoff=si->rdhoff/fak; if(hoff & 1 ) error(E_INTERN);
X hlen=si->rdhlen/fak; if(hlen & 1 ) error(E_INTERN); hende=hlen+hoff;
X voff=si->rdvoff/fak; if(voff & 1 ) error(E_INTERN);
X vlen=si->rdvlen/fak; if(vlen & 1 ) error(E_INTERN); vende=vlen+voff;
X }
X
X
X if(!f) error(E_INTERN);
X
X#ifdef DEBUG
X fprintf(stderr,"fak %d\n",fak);
X fprintf(stderr,"f->im %x \n",(unsigned)f->im);
X fprintf(stderr,"f->iheight %d %d\n",f->iheight,vlen);
X fprintf(stderr,"f->iwidth %d %d\n",f->iwidth,hlen);
X fprintf(stderr,"hoffset %d hende %d voffset %d vende %d\n",hoff,hende,voff,vende);
X#endif
X
X if((! f->im) || ( f->iheight != vlen ) || (f->iwidth != hlen )) error(E_INTERN);
X
X
X switch(tag)
X {case 0: SETHUFF0; break;
X case 1: SETHUFF1; break;
X case 2: SETHUFF2; break;
X default: error(E_INTERN);
X }
X
X
X
X htlen=sreg=0;
X zeile=0;
X nextbuf;
X inh=32;
X lptr=0;
X part=do_inform=0;
X shiftout(16);
X shiftout(16);
X
X if(autosync) seeksync;
X
X if(!issync)
X { if(!do_rep) error(E_SEQ6);
X else
X {fprintf(stderr,"Image does not start with synchron mark, seeking...\n");
X seeksync;
X do_inform=1;
X }
X }
X
X
X n=pos=0;
X
X
X for(;;)
X {if (issync)
X {shiftout(24);
X ident=(sreg>>8) & 0xffffff;
X shiftout(24);
X
X segment=(ident>>20) & 0xf;
X zeile =(ident>>6 ) & 0x3fff;
X sector =(ident>>1 ) & 0x1f;
X
X if(segment != tag) {fprintf(stderr,"Falsches Segment\n"); return;}
X if(do_inform) {fprintf(stderr,"Synchron mark found Line %d\n",zeile);do_inform=0;}
X
X if(zeile < voff ) {n=maxwidth; seeksync; continue;}
X if(zeile >= vende) return;
X
X
X
X#ifdef DEBUG
X fprintf(stderr,"Id %4x Zeile: %6d Seg %3d Sect %d Pix bisher: %5d \n",
X ident,zeile,segment,sector,n);
X#endif
X
X
X if(lptr && (n!=maxwidth))
X {if(!do_rep)error(E_SEQ1);
X else fprintf(stderr,"Line %d in %s : wrong length of last line (%d)\n",zeile,pn[part],n);
X }
X
X
X n=0;
X
X if(zeile==h) {RPRINT; return; }
X if(zeile >h)
X { if(!do_rep) error(E_SEQ2);
X else
X {fprintf(stderr,"Wrong line number %d, ignoring line\n",zeile);
X seeksync;
X n=maxwidth;
X do_inform=1;
X }
X }
X else
X {switch(tag)
X {case 0: anfang=hoff; ende=hende;
X pos=offset + sector*length;
X if((pos>=ende) || (pos+length < anfang)) { n=maxwidth; seeksync; continue;}
X lptr=f->im + (zeile-voff)*f->mwidth + (pos>anfang?(pos-anfang):0) ;
X
X break;
X case 1:
X case 2: anfang=hoff; ende=hende;
X pos=(offset>>1) + sector*length;
X if((pos>=ende) || (pos+length < anfang)) { n=maxwidth; seeksync; continue;}
X lptr=f->im + (zeile-voff)*f->mwidth + (pos>anfang?(pos-anfang):0) ;
X
X break;
X
X
X default: error(E_INTERN);
X }
X }
X }
X else /* for if (issync) */
X {if(!lptr) error(E_SEQ6);
X
X FINDHUFF(hp);
X if(!hp)
X { if(!do_rep) error(E_SEQ5);
X fprintf(stderr,"Unable to decode %08x, ignoring rest of line\n",sreg);
X seeksync;
X n=maxwidth;
X do_inform=1;
X }
X else
X {if((pos >= anfang) && (pos<ende))
X {sum=((sINT)(*lptr)) + ((sBYTE)hp->key);
X NORM(sum);
X *(lptr++) = sum;
X }
X n++; pos++;
X shiftout(hp->len);
X if(n==maxwidth)
X { if ((zeile >= vende -1) && (pos >= hende)) return;
X seeksync;
X }
X }
X }
X }
X
X
X
X
X#undef nextbuf
X#undef checkbuf
X#undef shiftout
X#undef issync
X#undef seeksync
X
X }
X
X
X
X
X
X
X
X
X
X
X
X
Xenum ERRORS readplain(sizeinfo *si,int fak,implane *l,implane *c1,implane *c2)
X {dim i,w,h,hoff,hlen,voff,vlen;
X uBYTE *pl=0,*pc1=0,*pc2=0;
X
X melde("readplain\n");
X
X#ifdef DEBUG
X fprintf(stderr,"readplain %d %d %d %d %d %d %d\n",fak,si->w,si->h,si->rdhoff,si->rdhlen,si->rdvoff,si->rdvlen);
X#endif
X
X if(fak >= 0)
X {w =si->w *fak;
X h =si->h *fak;
X hoff=si->rdhoff*fak; if(hoff & 1 ) error(E_INTERN); /* Must be all even */
X hlen=si->rdhlen*fak; if(hlen & 1 ) error(E_INTERN);
X voff=si->rdvoff*fak; if(voff & 1 ) error(E_INTERN);
X vlen=si->rdvlen*fak; if(vlen & 1 ) error(E_INTERN);
X }
X else
X {fak = -fak;
X w =si->w /fak;
X h =si->h /fak;
X hoff=si->rdhoff/fak; if(hoff & 1 ) error(E_INTERN); /* Must be all even */
X hlen=si->rdhlen/fak; if(hlen & 1 ) error(E_INTERN);
X voff=si->rdvoff/fak; if(voff & 1 ) error(E_INTERN);
X vlen=si->rdvlen/fak; if(vlen & 1 ) error(E_INTERN);
X }
X
X
X
X if(l)
X { if ((l->mwidth<hlen) || (l->mheight<vlen) || (!l->im)) error(E_INTERN);
X l->iwidth=hlen;
X l->iheight=vlen;
X pl=l->im;
X }
X
X if(c1)
X { if ((c1->mwidth<(hlen>>1)) || (c1->mheight<(vlen>>1)) || (!c1->im)) error(E_INTERN);
X c1->iwidth=hlen>>1;
X c1->iheight=vlen>>1;
X pc1=c1->im;
X }
X
X if(c2)
X { if ((c2->mwidth<(hlen>>1)) || (c2->mheight<(vlen>>1)) || (!c2->im)) error(E_INTERN);
X c2->iwidth=hlen>>1;
X c2->iheight=vlen>>1;
X pc2=c2->im;
X }
X
X if(voff) SKIPr(w*3*(voff>>1));
X
X for(i=0;i<vlen>>1;i++)
X {
X if(pl)
X { if(hlen==w)
X {if(READ(pl,w)<1) return(E_READ);
X pl+= l->mwidth;
X
X if(READ(pl,w)<1) return(E_READ);
X pl+= l->mwidth;
X }
X else
X {SKIPr(hoff);
X
X if(READ(pl,hlen)<1) return(E_READ);
X pl+= l->mwidth;
X
X SKIPr(w-hlen); /* w - hlen - hoff + hoff */
X
X if(READ(pl,hlen)<1) return(E_READ);
X pl+= l->mwidth;
X
X SKIPr(w-hoff-hlen);
X }
X }
X else SKIPr(2*w);
X
X if(pc1)
X {
X if(hlen==w)
X {
X if(READ(pc1,w>>1)<1) return(E_READ);
X pc1+= c1->mwidth;
X }
X else
X {SKIPr((hoff)>>1);
X if(READ(pc1,hlen>>1)<1) return(E_READ);
X pc1+= c1->mwidth;
X SKIPr((w-hoff-hlen)>>1);
X }
X }
X else SKIPr(w>>1);
X
X if(pc2)
X {
X if(hlen==w)
X {
X if(READ(pc2,w>>1)<1) return(E_READ);
X pc2+= c2->mwidth;
X }
X else
X {SKIPr((hoff)>>1);
X if(READ(pc2,hlen>>1)<1) return(E_READ);
X pc2+= c2->mwidth;
X SKIPr((w-hoff-hlen)>>1);
X }
X }
X else SKIPr(w>>1);
X
X
X }
X RPRINT;
X return E_NONE;
X }
END_OF_FILE
if test 18842 -ne `wc -c <'hpcdtoppm.0.6/format.c'`; then
echo shar: \"'hpcdtoppm.0.6/format.c'\" unpacked with wrong size!
fi
# end of 'hpcdtoppm.0.6/format.c'
fi
if test -f 'hpcdtoppm.0.6/postscr.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'hpcdtoppm.0.6/postscr.c'\"
else
echo shar: Extracting \"'hpcdtoppm.0.6/postscr.c'\" \(10053 characters\)
sed "s/^X//" >'hpcdtoppm.0.6/postscr.c' <<'END_OF_FILE'
X/* hpcdtoppm (Hadmut's pcdtoppm) v0.6
X* Copyright (c) 1992, 1993, 1994 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#define DITH_NEUTR 128
X
XFLTPT PAPER_LEFT =DEF_PAPER_LEFT;
XFLTPT PAPER_BOTTOM =DEF_PAPER_BOTTOM;
XFLTPT PAPER_WIDTH =DEF_PAPER_WIDTH;
XFLTPT PAPER_HEIGHT =DEF_PAPER_HEIGHT;
XFLTPT PRINTER_XDPI =DEF_DPI;
XFLTPT PRINTER_YDPI =DEF_DPI;
XFLTPT PRINTER_FAK =1.0;
XsINT PSIZE_SET=0,DPI_SET=0,FAK_SET=0;
X
X
Xstatic char pshdr[]="%%Creator: hpcdtoppm v0.6\n";
Xstatic char hex[]="0123456789ABCDEF";
X#define HEX(x) {fputc(hex[((x)>>4)&0xf],fout);fputc(hex[(x)&0xf],fout);}
X
X
X/* find an appropriate scaling coefficient and generate a ps header
X * including a BoundingBox comment and a translate/scale sequence to
X * fit the pixw*pixh image into a square on paper with PS user coordinates
X * x,y,w,h
X */
Xstatic void size_dependant(FILE *fout,sINT pixw,sINT pixh,
X FLTPT x,FLTPT y,FLTPT w,FLTPT h)
X{ FLTPT scale=(FLTPT)w/pixw,scaley=(FLTPT)h/pixh;
X
X if(scale>scaley) scale=scaley;
X x+=w/2.0;y+=h/2.0;
X fprintf(fout,"%%%%BoundingBox: %.8g %.8g %.8g %.8g\n",
X x-scale*pixw/2.0,y-scale*pixh/2.0,
X x+scale*pixw/2.0,y+scale*pixh/2.0);
X fprintf(fout,"%s",pshdr);
X fputs("%%Pages: 1 1\n",fout);
X
X if(pcdname) fprintf(fout,"%%%%Title: %s\n",pcdname);
X fputs("%%EndComments\n\n",fout);
X
X fprintf(fout,"%f %f translate\n",x-scale*pixw/2.0,y-scale*pixh/2.0);
X fprintf(fout,"%f %f scale\n",scale*pixw,scale*pixh);
X}
X
X
X
Xstatic void end_postscript(FILE *fout)
X {
X fputs("%%EOF\n\n",fout);
X }
X
X
X
X
Xstatic void sub_psgrey(FILE *fout,dim w,dim h, uBYTE *ptr,sdim zeil,sdim pix)
X{ dim x,y;
X register uBYTE *p;
X sINT c;
X
X size_dependant(fout,w,h,PAPER_LEFT,PAPER_BOTTOM,PAPER_WIDTH,PAPER_HEIGHT);
X fprintf(fout,"%d string\n",w);
X fprintf(fout,"%d %d 8\n",w,h); /* always 8 bit per channel */
X fprintf(fout,"[%d 0 0 %d 0 %d]\n",w,-h,h);
X fputs("{currentfile 1 index readhexstring pop} image\n",fout);
X
X c=0;
X for(y=0;y<h;y++,ptr+=zeil)
X for(p=ptr,x=0;x<w;x++,p+=pix)
X {HEX(*p);
X if(!(++c % 36)) fputs("\n",fout);
X }
X
X fputs("\npop\n\n",fout);
X}
X
X
X
X
X
X
X
Xvoid write_epsgrey(FILE *fout,dim w,dim h, uBYTE *ptr,sdim zeil,sdim pix)
X{
X fputs("%!PS-Adobe-2.0 EPSF-2.0\n",fout);
X sub_psgrey(fout,w,h, ptr,zeil,pix);
X end_postscript(fout);
X}
X
Xvoid write_psgrey(FILE *fout,dim w,dim h, uBYTE *ptr,sdim zeil,sdim pix)
X{
X fputs("%!PS-Adobe-2.0\n",fout);
X sub_psgrey(fout,w,h, ptr,zeil,pix);
X fputs("showpage\n",fout);
X end_postscript(fout);
X}
X
X
X
X
X
X
X
X
X
X
X
Xstatic void sub_psrgb(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{ dim x,y;
X register uBYTE *pr,*pg,*pb;
X sINT c;
X
X size_dependant(fout,w,h,PAPER_LEFT,PAPER_BOTTOM,PAPER_WIDTH,PAPER_HEIGHT);
X fprintf(fout,"%d string\n",w*3);
X fprintf(fout,"%d %d 8\n",w,h); /* always 8 bit per channel */
X fprintf(fout,"[%d 0 0 %d 0 %d]\n",w,-h,h);
X fputs("{currentfile 1 index readhexstring pop} false 3 colorimage\n",fout);
X
X c=0;
X for(y=0;y<h;y++,rptr+=rzeil,gptr+=gzeil,bptr+=bzeil)
X for(pr=rptr,pg=gptr,pb=bptr,x=0;x<w;x++,pr+=rpix,pg+=gpix,pb+=bpix)
X {HEX(*pr);HEX(*pg);HEX(*pb);
X if(!(++c % 12)) fputs("\n",fout);
X }
X
X fputs("\npop\n\n",fout);
X}
X
X
Xvoid write_epsrgb(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{
X fputs("%!PS-Adobe-2.0 EPSF-2.0\n",fout);
X sub_psrgb(fout,w,h, rptr,rzeil,rpix,gptr,gzeil,gpix,bptr,bzeil,bpix);
X end_postscript(fout);
X}
X
X
X
Xvoid write_psrgb(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{
X fputs("%!PS-Adobe-2.0\n",fout);
X sub_psrgb(fout,w,h, rptr,rzeil,rpix,gptr,gzeil,gpix,bptr,bzeil,bpix);
X fputs("showpage\n",fout);
X end_postscript(fout);
X}
X
X
X
X
X
X
X
X
X
Xtypedef sINT dt;
Xextern sINT dithtab[];
X#define DS 4
X#define DA (1<<(DS-1))
X#define DT 127
X
Xstatic void fakcopy(dim worig,dim horig, uBYTE *ptr1,sdim zeil,sdim pix,
X sdim wx,sINT zn,dt *dest)
X {FLTPT owf,ohf,wbruch,hbruch,m1,m2,ha,hb;
X dim owd,ohd,x;
X uBYTE *ptr2;
X sINT md;
X
X ohf=zn/PRINTER_FAK;
X ohd=(dim)ohf;
X hbruch=ohf-(FLTPT)ohd;
X if(ohd>=horig) error(E_INTERN);
X
X ptr1+=zeil*ohd;
X ptr2= (ohd < horig - 1) ? ptr1+zeil : ptr1;
X
X dest[-1]=DITH_NEUTR;
X
X for(x=0;x<wx;x++)
X {owf=x/PRINTER_FAK;
X owd=(dim)owf;
X wbruch=owf-(FLTPT)owd;
X if(owd>=worig) error(E_INTERN);
X
X if(owd<worig-1)
X {ha=(FLTPT)ptr1[owd*pix];
X hb=(FLTPT)ptr1[(owd+1)*pix];
X m1=ha+wbruch*(hb-ha);
X
X ha=(FLTPT)ptr2[owd*pix];
X hb=(FLTPT)ptr2[(owd+1)*pix];
X m2=ha+wbruch*(hb-ha);
X }
X else
X { m1=(FLTPT)ptr1[owd*pix];
X m2=(FLTPT)ptr2[owd*pix];
X }
X md=(sINT)(m1+hbruch*(m2-m1));
X if(md<0 || md>255) {fprintf(stderr,"md %d\n",md); error(E_INTERN);}
X *(dest++)=dithtab[md];
X
X }
X
X dest[0]=DITH_NEUTR;
X }
X
Xstatic void sub_psdith(FILE *fout,dim worig,dim horig, uBYTE *ptr,sdim zeil,sdim pix)
X{ register uBYTE *p;
X sINT c,i,ii,j,reg,bit;
X dt new,diff;
X dt *dP1,*dP2,*akt,*nex,*help,*rrun;
X dim ww=0,wl=0,wr=0,hh=0,ho=0,hu=0,wx=0,hx=0;
X int ccase;
X FLTPT PW=0.0,PH=0.0;
X
X#define copy(n,d) {if(FAK_SET) fakcopy(worig,horig,ptr,zeil,pix,wx,n,d); \
X else{p=ptr+((n)*zeil); rrun=d;\
X for(ii=0;ii<wx;ii++,p+=pix,rrun++) *rrun = dithtab[*p]; \
X d[-1]=d[wx]=DITH_NEUTR; }}
X
X
X#define pr(x) { reg= (reg<<1) | x; bit++; \
X if(bit==8) {HEX(reg); \
X if(!(++c % 36)) fputs("\n",fout);\
X bit=reg=0;}}
X
X#define flush { while(bit) pr(1); }
X#define fill pr(1)
X
X
X
X#define MakeFit(wi,he) { ww=(wi+7) & (~7); wl=(ww-wi)/2; wr=ww-wi-wl; \
X hh=(he+7) & (~7); ho=(hh-he)/2; hu=hh-he-ho; }
X
X
X
X ccase=( FAK_SET ? 4 : 0 ) |
X ( DPI_SET ? 2 : 0 ) |
X ( PSIZE_SET ? 1 : 0 ) ;
X
X
X switch (ccase)
X {case 0: /* no option or -dpi option */
X case 2: hx=horig;
X wx=worig;
X MakeFit(wx,hx);
X PW=ww*72.0/PRINTER_XDPI;
X PH=hh*72.0/PRINTER_YDPI;
X break;
X
X case 1: /* paper size set with -pw and/or -ph */
X hx=horig;
X wx=worig;
X MakeFit(wx,hx);
X PW=PAPER_WIDTH;
X PH=PAPER_HEIGHT;
X break;
X
X case 6: /* -fak option (and perhaps -dpi) */
X case 4: hx=PRINTER_FAK*horig+0.5;
X wx=PRINTER_FAK*worig+0.5;
X MakeFit(wx,hx);
X PW=ww*72.0/PRINTER_XDPI;
X PH=hh*72.0/PRINTER_YDPI;
X break;
X
X case 5: /* -fak and papersize */
X hx=PRINTER_FAK*horig+0.5;
X wx=PRINTER_FAK*worig+0.5;
X MakeFit(wx,hx);
X PW=PAPER_WIDTH;
X PH=PAPER_HEIGHT;
X break;
X
X case 3: /* papersize and dpi set, probably the most important case */
X PW=PAPER_WIDTH;
X PH=PAPER_HEIGHT;
X
X FAK_SET=1;
X {FLTPT fw,fh;
X fw=PW/72.0*PRINTER_XDPI/worig;
X fh=PH/72.0*PRINTER_YDPI/horig;
X PRINTER_FAK=MIN(fw,fh);
X }
X hx=PRINTER_FAK*horig+0.5;
X wx=PRINTER_FAK*worig+0.5;
X MakeFit(wx,hx);
X PW=ww*72.0/PRINTER_XDPI;
X PH=hh*72.0/PRINTER_YDPI;
X break;
X
X
X case 7: /* size, dpi and factor set, this case should have been
X cought earlier... */
X default: error(E_INTERN);
X };
X
X if(FAK_SET && (PRINTER_FAK<=0.0 || PRINTER_FAK >=1000.0)) error(E_PRPAR);
X if(PW<=0.0 || PH<=0.0) error(E_PRPAR);
X
X if(wx < 4 || hx < 4) error(E_PRPAR);
X
X
X if (!(dP1=(dt *)malloc((wx+2)*sizeof(dt)))) error(E_MEM);
X if (!(dP2=(dt *)malloc((wx+2)*sizeof(dt)))) error(E_MEM);
X
X
X
X size_dependant(fout,ww,hh,PAPER_LEFT,PAPER_BOTTOM,PW,PH);
X
X fprintf(fout,"%d string\n",ww);
X fprintf(fout,"%d %d 1\n",ww,hh); /* always 8 bit per channel */
X fprintf(fout,"[%d 0 0 %d 0 %d]\n",ww,-hh,hh);
X fputs("{currentfile 1 index readhexstring pop} image\n",fout);
X
X c=bit=reg=0;
X akt=dP1+1;
X nex=dP2+1;
X
X for(i=0;i<ho;i++)
X for(j=0;j<ww;j++)
X fill;
X
X copy(0,nex);
X for(i=0;i<hx;i++)
X {help=akt; akt=nex; nex=help;
X if(i<hx-1) copy(i+1,nex);
X
X if(i&1)
X for(j=0;j<wx;j++)
X { new=akt[j]>DT ? 255 : 0;
X diff = akt[j]-new;
X akt[j]=new;
X akt[j+1]+=(diff*7 + DA)>>DS;
X nex[j+1]+=(diff + DA)>>DS;
X nex[j ]+=(diff*5 + DA)>>DS;
X nex[j-1]+=(diff*3 + DA)>>DS;
X }
X else
X for(j=wx-1;j>=0;j--)
X { new=akt[j]>DT ? 255 : 0;
X diff = akt[j]-new;
X akt[j]=new;
X akt[j-1]+=(diff*7 + DA)>>DS;
X nex[j-1]+=(diff + DA)>>DS;
X nex[j ]+=(diff*5 + DA)>>DS;
X nex[j+1]+=(diff*3 + DA)>>DS;
X }
X
X
X for(j=0;j<wl;j++) fill;
X
X for(j=0;j<wx;j++)
X {if (akt[j]>DT) { pr(1); }
X else { pr(0); }
X }
X
X for(j=0;j<wr;j++) fill;
X
X flush;
X }
X
X for(i=0;i<hu;i++)
X for(j=0;j<ww;j++)
X fill;
X flush;
X
X fputs("\npop\n\n",fout);
X free(dP1);
X free(dP2);
X}
X
X
Xvoid write_epsdith(FILE *fout,dim w,dim h, uBYTE *ptr,sdim zeil,sdim pix)
X{
X fputs("%!PS-Adobe-2.0 EPSF-2.0\n",fout);
X sub_psdith(fout,w,h, ptr,zeil,pix);
X end_postscript(fout);
X}
X
Xvoid write_psdith(FILE *fout,dim w,dim h, uBYTE *ptr,sdim zeil,sdim pix)
X{
X fputs("%!PS-Adobe-2.0\n",fout);
X sub_psdith(fout,w,h, ptr,zeil,pix);
X fputs("showpage\n",fout);
X end_postscript(fout);
X}
X
X
X
END_OF_FILE
if test 10053 -ne `wc -c <'hpcdtoppm.0.6/postscr.c'`; then
echo shar: \"'hpcdtoppm.0.6/postscr.c'\" unpacked with wrong size!
fi
# end of 'hpcdtoppm.0.6/postscr.c'
fi
if test -f 'hpcdtoppm.0.6/ppm.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'hpcdtoppm.0.6/ppm.c'\"
else
echo shar: Extracting \"'hpcdtoppm.0.6/ppm.c'\" \(3053 characters\)
sed "s/^X//" >'hpcdtoppm.0.6/ppm.c' <<'END_OF_FILE'
X/* hpcdtoppm (Hadmut's pcdtoppm) v0.6
X* Copyright (c) 1992, 1993, 1994 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 3053 -ne `wc -c <'hpcdtoppm.0.6/ppm.c'`; then
echo shar: \"'hpcdtoppm.0.6/ppm.c'\" unpacked with wrong size!
fi
# end of 'hpcdtoppm.0.6/ppm.c'
fi
echo shar: End of archive 2 \(of 3\).
cp /dev/null ark2isdone
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...