#!/bin/rc # # command: /bin/boddle /n/juke/plan_9/sys/src/fb /sys/src/fb # srcdir: /n/juke/plan_9/sys/src/fb # version: 836422821 # date: Wed Jul 3 15:40:21 EDT 1996 # myname=$0 doextract=no fn usage{ echo $myname: usage: $myname '[-X] [src-directory]' >[1=2] exit usage } fn sigint{ rm -rf 836422821 exit interrupt } while(~ $1 -*){ switch($1){ case -X doextract=yes case -* usage } shift } switch($#*){ case 0 srcdir=/sys/src/fb case 1 srcdir=$1 case * usage } if(! ~ $doextract yes){ echo This shell file contains a bundle of diffs representing changes echo to original source files in the Plan 9 distribution. It will run echo against the files in echo ' ' $srcdir echo '(unless overridden by the optional source directory argument)' echo and create a directory 836422821 containing the updated files. echo It will NOT automatically update the original files. echo echo Invoke with argument -X to perform the actual extraction. exit 0 } rm -rf 836422821 mkdir 836422821 target=836422821/3to1.c echo -n '836422821/3to1.c: ' if(! test -f $srcdir/3to1.c || ! test -r $srcdir/3to1.c){ echo $srcdir/3to1.c unreadable exit unreadable } sum=`{sum < $srcdir/3to1.c} if(! ~ d44388ef7453 $sum(1)^$sum(2)){ echo $srcdir/3to1.c is not the original distribution file exit original } cp $srcdir/3to1.c 836422821/3to1.c ed 836422821/3to1.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM 3to1.c' 91c for(op=outbuf,ip=inbuf+offs,e=error;op!=eop;op++,ip+=nchan,e+=3){ . 7d wq //GO.SYSIN DD VADIM 3to1.c sum=`{sum < 836422821/3to1.c} if(~ 8f30ef4d7433 $sum(1)^$sum(2)) echo if not{ echo 836422821/3to1.c checksum error creating updated file exit checksum } target=836422821/9v.c echo -n '836422821/9v.c: ' if(! test -f $srcdir/9v.c || ! test -r $srcdir/9v.c){ echo $srcdir/9v.c unreadable exit unreadable } sum=`{sum < $srcdir/9v.c} if(! ~ 95b6c67210910 $sum(1)^$sum(2)){ echo $srcdir/9v.c is not the original distribution file exit original } cp $srcdir/9v.c 836422821/9v.c ed 836422821/9v.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM 9v.c' 432,433c size=Pt(max(wid+4*BORDER, 100), max(hgt+5*BORDER+FONTHGT+TOPAIR+BOTAIR, 50)); . 337a ".GIF", "/bin/fb/gif2pic -m %s", . wq //GO.SYSIN DD VADIM 9v.c sum=`{sum < 836422821/9v.c} if(~ 476c205610945 $sum(1)^$sum(2)) echo if not{ echo 836422821/9v.c checksum error creating updated file exit checksum } target=836422821/aplot.c echo -n '836422821/aplot.c: ' if(! test -f $srcdir/aplot.c || ! test -r $srcdir/aplot.c){ echo $srcdir/aplot.c unreadable exit unreadable } sum=`{sum < $srcdir/aplot.c} if(! ~ ddbcd2109614 $sum(1)^$sum(2)){ echo $srcdir/aplot.c is not the original distribution file exit original } cp $srcdir/aplot.c 836422821/aplot.c ed 836422821/aplot.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM aplot.c' 54,59c cvt(cint, int) cvt(cshort, short) cvt(clong, long) cvt(cdouble, double) cvt(cchar, char) cvt(cuchar, unsigned char) . 7d wq //GO.SYSIN DD VADIM aplot.c sum=`{sum < 836422821/aplot.c} if(~ dc4864cd9590 $sum(1)^$sum(2)) echo if not{ echo 836422821/aplot.c checksum error creating updated file exit checksum } target=836422821/card.c echo -n '836422821/card.c: ' if(! test -f $srcdir/card.c || ! test -r $srcdir/card.c){ echo $srcdir/card.c unreadable exit unreadable } sum=`{sum < $srcdir/card.c} if(! ~ 925da4fd1630 $sum(1)^$sum(2)){ echo $srcdir/card.c is not the original distribution file exit original } cp $srcdir/card.c 836422821/card.c ed 836422821/card.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM card.c' 6d wq //GO.SYSIN DD VADIM card.c sum=`{sum < 836422821/card.c} if(~ 44b6db581612 $sum(1)^$sum(2)) echo if not{ echo 836422821/card.c checksum error creating updated file exit checksum } target=836422821/cmap.c echo -n '836422821/cmap.c: ' if(! test -f $srcdir/cmap.c || ! test -r $srcdir/cmap.c){ echo $srcdir/cmap.c unreadable exit unreadable } sum=`{sum < $srcdir/cmap.c} if(! ~ eec45cc11309 $sum(1)^$sum(2)){ echo $srcdir/cmap.c is not the original distribution file exit original } cp $srcdir/cmap.c 836422821/cmap.c ed 836422821/cmap.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM cmap.c' 6d wq //GO.SYSIN DD VADIM cmap.c sum=`{sum < 836422821/cmap.c} if(~ f81c24591291 $sum(1)^$sum(2)) echo if not{ echo 836422821/cmap.c checksum error creating updated file exit checksum } target=836422821/colors.c echo -n '836422821/colors.c: ' if(! test -f $srcdir/colors.c || ! test -r $srcdir/colors.c){ echo $srcdir/colors.c unreadable exit unreadable } sum=`{sum < $srcdir/colors.c} if(! ~ 4a5ad4d33600 $sum(1)^$sum(2)){ echo $srcdir/colors.c is not the original distribution file exit original } cp $srcdir/colors.c 836422821/colors.c ed 836422821/colors.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM colors.c' 142d wq //GO.SYSIN DD VADIM colors.c sum=`{sum < 836422821/colors.c} if(~ 047866453587 $sum(1)^$sum(2)) echo if not{ echo 836422821/colors.c checksum error creating updated file exit checksum } target=836422821/cpr.c echo -n '836422821/cpr.c: ' if(! test -f $srcdir/cpr.c || ! test -r $srcdir/cpr.c){ echo $srcdir/cpr.c unreadable exit unreadable } sum=`{sum < $srcdir/cpr.c} if(! ~ 477eab1d16994 $sum(1)^$sum(2)){ echo $srcdir/cpr.c is not the original distribution file exit original } cp $srcdir/cpr.c 836422821/cpr.c ed 836422821/cpr.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM cpr.c' 94a void depthclip(void); void geode(Point3 *a, Point3 *b, Point3 *c, Point3 cen, double r, int c1, int c2, int n); int getnormal(void); void input(FILE *ifd); void insert(struct edge *e, struct edge **bp); double len(Point3 p); void main(int argc, char *argv[]); char *mkchan(void); void normalize(Point3 *v); void outline(PICFILE *f, unsigned char *p); void polyren(int c, int other); void readbg(FILE *f); void readcolor(FILE *f); void readcomment(FILE *f); void readheight(FILE *f); void readlight(FILE *f); void readmat(FILE *f); void readpoly(FILE *f); void readpop(FILE *f); void readpush(FILE *f); void readquat(FILE *f); void readrot(FILE *f); void readscale(FILE *f); void readsphere(FILE *f); void readtran(FILE *f); void readtri(FILE *f); void readview(FILE *f); void span(int z, double x0, double y0, double x1, double y1); . 26,53d wq //GO.SYSIN DD VADIM cpr.c sum=`{sum < 836422821/cpr.c} if(~ 41eb847a16994 $sum(1)^$sum(2)) echo if not{ echo 836422821/cpr.c checksum error creating updated file exit checksum } target=836422821/dither.c echo -n '836422821/dither.c: ' if(! test -f $srcdir/dither.c || ! test -r $srcdir/dither.c){ echo $srcdir/dither.c unreadable exit unreadable } sum=`{sum < $srcdir/dither.c} if(! ~ 5aa9590a2649 $sum(1)^$sum(2)){ echo $srcdir/dither.c is not the original distribution file exit original } cp $srcdir/dither.c 836422821/dither.c ed 836422821/dither.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM dither.c' 13d wq //GO.SYSIN DD VADIM dither.c sum=`{sum < 836422821/dither.c} if(~ 02d9edc92631 $sum(1)^$sum(2)) echo if not{ echo 836422821/dither.c checksum error creating updated file exit checksum } target=836422821/dumppic.c echo -n '836422821/dumppic.c: ' if(! test -f $srcdir/dumppic.c || ! test -r $srcdir/dumppic.c){ echo $srcdir/dumppic.c unreadable exit unreadable } sum=`{sum < $srcdir/dumppic.c} if(! ~ 909e2b521090 $sum(1)^$sum(2)){ echo $srcdir/dumppic.c is not the original distribution file exit original } cp $srcdir/dumppic.c 836422821/dumppic.c ed 836422821/dumppic.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM dumppic.c' 3d wq //GO.SYSIN DD VADIM dumppic.c sum=`{sum < 836422821/dumppic.c} if(~ 7647f0b81072 $sum(1)^$sum(2)) echo if not{ echo 836422821/dumppic.c checksum error creating updated file exit checksum } target=836422821/face2pic.c echo -n '836422821/face2pic.c: ' if(! test -f $srcdir/face2pic.c || ! test -r $srcdir/face2pic.c){ echo $srcdir/face2pic.c unreadable exit unreadable } sum=`{sum < $srcdir/face2pic.c} if(! ~ 866f79a61734 $sum(1)^$sum(2)){ echo $srcdir/face2pic.c is not the original distribution file exit original } cp $srcdir/face2pic.c 836422821/face2pic.c ed 836422821/face2pic.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM face2pic.c' 6d wq //GO.SYSIN DD VADIM face2pic.c sum=`{sum < 836422821/face2pic.c} if(~ 9eb211231716 $sum(1)^$sum(2)) echo if not{ echo 836422821/face2pic.c checksum error creating updated file exit checksum } target=836422821/filter.cc echo -n '836422821/filter.cc: ' if(! test -f $srcdir/filter.cc || ! test -r $srcdir/filter.cc){ echo $srcdir/filter.cc unreadable exit unreadable } sum=`{sum < $srcdir/filter.cc} if(! ~ 548b842c1193 $sum(1)^$sum(2)){ echo $srcdir/filter.cc is not the original distribution file exit original } cp $srcdir/filter.cc 836422821/filter.cc ed 836422821/filter.cc >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM filter.cc' 3d wq //GO.SYSIN DD VADIM filter.cc sum=`{sum < 836422821/filter.cc} if(~ c2a84c511175 $sum(1)^$sum(2)) echo if not{ echo 836422821/filter.cc checksum error creating updated file exit checksum } target=836422821/floyd.c echo -n '836422821/floyd.c: ' if(! test -f $srcdir/floyd.c || ! test -r $srcdir/floyd.c){ echo $srcdir/floyd.c unreadable exit unreadable } sum=`{sum < $srcdir/floyd.c} if(! ~ 2d921e7e1895 $sum(1)^$sum(2)){ echo $srcdir/floyd.c is not the original distribution file exit original } cp $srcdir/floyd.c 836422821/floyd.c ed 836422821/floyd.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM floyd.c' 7d wq //GO.SYSIN DD VADIM floyd.c sum=`{sum < 836422821/floyd.c} if(~ 22b64fe81877 $sum(1)^$sum(2)) echo if not{ echo 836422821/floyd.c checksum error creating updated file exit checksum } target=836422821/gif2pic.c echo -n '836422821/gif2pic.c: ' if(! test -f $srcdir/gif2pic.c || ! test -r $srcdir/gif2pic.c){ echo $srcdir/gif2pic.c unreadable exit unreadable } sum=`{sum < $srcdir/gif2pic.c} if(! ~ 25c4dd3d10300 $sum(1)^$sum(2)){ echo $srcdir/gif2pic.c is not the original distribution file exit original } cp $srcdir/gif2pic.c 836422821/gif2pic.c ed 836422821/gif2pic.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM gif2pic.c' 397,398c if(image.ncmap){ if(flag['9']){ remap9(); setmap9(image.cmap); } else if(flag['v']){ remaprgbv(); setmaprgbv(image.cmap); } else remap(); } p=picopen_w("OUT", flag['t']?flag['t'][0]:"runcode", image.left, image.top, image.wid, image.hgt, . 373c argc=getflags(argc, argv, "t:1[type]m9vs:1[image #]n:1[name]"); . 368a void setmap9(uchar cmap[256][3]){ int r, g, b; int i; for(r=0,i=0;r!=8;r++) for(g=0;g!=8;g++) for(b=0;b!=4;b++,i++){ cmap[i][0]=r*0x49/2; cmap[i][1]=g*0x49/2; cmap[i][2]=b*0x55; } for(i=85;i<=255;i+=85) cmap[i][0]=cmap[i][1]=cmap[i][2]=i; } /* * Remap colors to use default Plan 9 colormap, with ordered dithering. * If incoming color is a shade of gray, map to one of * 0 (r=g=b=0), 85 (r=g=b=128), 170 (r=g=b=181), or 255 (r=g=b=255) * Otherwise, avoid gray pixels (85 and 170) by moving one shade of red */ void remap9(void) { int r, g, b, v, wid, hgt, xx, y, yy; byte *p, *pe, *cm; int *drg, *db; byte *ci0, *ci1, *ci2; wid=image.wid; hgt=image.hgt; p=image.image; ci0=ci9[0]+255; ci1=ci9[1]+255; ci2=ci9[2]+255; for(y=0; y!=hgt; y++){ yy=y&15; pe=p+wid; drg=rgodither[yy]; db=bodither[yy]; xx=0; for(; p!=pe; p++){ cm=image.cmap[*p]; r=cm[0]; g=cm[1]; b=cm[2]; if(r==g && r==b){ r += db[xx]; if(r<=42) v=0; else if(r>=213) v=255; else if(r<=128) v=85; else v=170; }else{ v=ci0[r+drg[xx]]+ci1[g+drg[xx]]+ci2[b+db[xx]]; if(v==85) v=85-32; else if(v==170) v=170+32; } xx = (xx+1)&15; *p=v; } } } /* * rgbv colormap (really rvgb). * 2 bits precision in each of rgb, * the extra 2 bits used for more value precision. * * This gives 16 grey shades. Indexing is organized * so that for i=0..15 the grey shade (17*i, 17*i, 17*i) * is at index 17*i, to facilitate up-converting * 1, 2 and 4 bit grey-scale bitmaps. */ void setmaprgbv(uchar cmap[256][3]){ byte *c; int r, g, b, v; int num, den; int i, j; for(r=0,i=0;r!=4;r++) for(v=0;v!=4;v++,i+=16){ for(g=0,j=v-r;g!=4;g++) for(b=0;b!=4;b++,j++){ c=cmap[i+(j&15)]; den=r; if(g>den) den=g; if(b>den) den=b; if(den==0) /* divide check -- pick grey shades */ c[0]=c[1]=c[2]=17*v; else{ num=17*(4*den+v); c[0]=r*num/den; c[1]=g*num/den; c[2]=b*num/den; } } } } uchar closest[16][16][16]={ 0, 17, 17, 1, 1, 18, 35, 52, 2, 19, 36, 53, 3, 20, 37, 54, 17, 17, 17, 1, 1, 18, 35, 52, 2, 19, 36, 53, 3, 20, 37, 54, 17, 17, 34, 5, 5, 5, 35, 6, 6, 6, 23, 7, 7, 7, 24, 41, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 23, 7, 7, 7, 24, 41, 4, 4, 5, 5, 5, 22, 22, 6, 6, 23, 40, 40, 7, 24, 41, 41, 21, 21, 5, 5, 22, 22, 39, 39, 6, 23, 40, 57, 57, 24, 41, 58, 38, 38, 38, 9, 22, 39, 39, 56, 56, 40, 40, 57, 57, 57, 41, 58, 55, 55, 9, 9, 9, 39, 56, 56, 10, 10, 57, 11, 11, 11, 28, 58, 8, 8, 9, 9, 9, 9, 56, 10, 10, 10, 27, 11, 11, 11, 28, 45, 25, 25, 9, 9, 26, 26, 43, 10, 10, 27, 27, 44, 11, 28, 45, 45, 42, 42, 26, 26, 43, 43, 43, 60, 27, 27, 44, 44, 61, 28, 45, 62, 59, 59, 13, 13, 43, 60, 60, 14, 14, 44, 44, 61, 61, 15, 45, 62, 12, 12, 13, 13, 13, 60, 60, 14, 14, 14, 61, 61, 15, 15, 16, 62, 29, 29, 13, 13, 30, 30, 60, 14, 14, 31, 31, 15, 15, 16, 16, 33, 46, 46, 30, 30, 47, 47, 47, 31, 31, 32, 32, 32, 16, 16, 33, 33, 63, 63, 47, 47, 47, 48, 48, 48, 32, 32, 49, 49, 49, 33, 33, 50, 17, 17, 17, 1, 1, 18, 35, 52, 2, 19, 36, 53, 3, 20, 37, 54, 17, 17, 34, 34, 1, 18, 35, 52, 2, 19, 36, 53, 3, 20, 37, 54, 17, 34, 34, 34, 51, 5, 35, 6, 6, 6, 23, 7, 7, 7, 24, 41, 4, 34, 34, 51, 5, 5, 6, 6, 6, 6, 23, 7, 7, 7, 24, 41, 4, 4, 51, 5, 5, 22, 22, 6, 6, 23, 40, 40, 7, 24, 41, 41, 21, 21, 5, 5, 22, 22, 39, 39, 6, 23, 40, 57, 57, 24, 41, 58, 38, 38, 38, 9, 22, 39, 39, 56, 56, 40, 40, 57, 57, 57, 41, 58, 55, 55, 9, 9, 9, 39, 56, 56, 10, 10, 57, 11, 11, 11, 28, 58, 8, 8, 9, 9, 9, 9, 56, 10, 10, 10, 27, 11, 11, 11, 28, 45, 25, 25, 9, 9, 26, 26, 43, 10, 10, 27, 27, 44, 11, 28, 45, 45, 42, 42, 26, 26, 43, 43, 43, 60, 27, 27, 44, 44, 61, 28, 45, 62, 59, 59, 13, 13, 43, 60, 60, 14, 14, 44, 44, 61, 61, 15, 45, 62, 12, 12, 13, 13, 13, 60, 60, 14, 14, 14, 61, 61, 15, 15, 16, 62, 29, 29, 13, 13, 30, 30, 60, 14, 14, 31, 31, 15, 15, 16, 16, 33, 46, 46, 30, 30, 47, 47, 47, 31, 31, 32, 32, 32, 16, 16, 33, 33, 63, 63, 47, 47, 47, 48, 48, 48, 32, 32, 49, 49, 49, 33, 33, 50, 17, 17, 34, 64, 64, 64, 35, 65, 65, 65, 82, 66, 66, 66, 83,100, 17, 34, 34, 34, 51, 64, 35, 65, 65, 65, 82, 66, 66, 66, 83,100, 34, 34, 34, 51, 51, 51, 69, 69, 69, 69, 69, 70, 70, 70, 87, 87, 67, 34, 51, 51, 51, 68, 69, 69, 69, 69, 23, 70, 70, 70, 87, 41, 67, 51, 51, 51, 68, 68, 69, 69, 69, 69, 86, 70, 70, 70, 87,104, 67, 67, 51, 68, 68, 22, 39, 69, 69, 69, 40, 70, 70, 70, 87,104, 38, 38, 72, 72, 72, 39, 39, 56, 73, 73, 40, 57, 57, 74, 41, 58, 71, 71, 72, 72, 72, 72, 56, 73, 73, 73, 73, 74, 74, 74, 74, 91, 71, 71, 72, 72, 72, 72, 73, 73, 73, 73, 73, 74, 74, 74, 91, 91, 71, 71, 72, 72, 72, 72, 73, 73, 73, 27, 90, 74, 74, 91, 91, 45, 88, 88, 72, 26, 89, 43, 43, 73, 73, 90, 44, 44, 74, 91, 45,108, 75, 75, 76, 76, 76, 76, 60, 77, 77, 77, 44, 61, 78, 78, 78, 62, 75, 75, 76, 76, 76, 76, 60, 77, 77, 77, 77, 78, 78, 78, 78, 95, 75, 75, 76, 76, 76, 76, 77, 77, 77, 94, 94, 78, 78, 78, 95, 95, 92, 92, 93, 93, 93, 93, 47, 77, 94, 94, 32, 78, 78, 95, 95, 33, 109,109, 93, 47,110,110, 48, 94, 94, 32,111, 49, 95, 95, 33, 96, 79, 79, 64, 64, 64, 64, 65, 65, 65, 65, 82, 66, 66, 66, 83,100, 79, 34, 34, 51, 64, 64, 65, 65, 65, 65, 82, 66, 66, 66, 83,100, 67, 34, 51, 51, 51, 68, 69, 69, 69, 69, 82, 70, 70, 70, 87,100, 67, 51, 51, 51, 68, 68, 69, 69, 69, 69, 86, 70, 70, 70, 87,104, 67, 67, 51, 68, 68, 68, 69, 69, 69, 69, 86, 70, 70, 70, 87,104, 67, 67, 68, 68, 68, 85, 85, 69, 69, 86, 86, 70, 70, 87, 87,104, 71, 71, 72, 72, 72, 85, 85, 73, 73, 86,103,103, 74, 87,104,104, 71, 71, 72, 72, 72, 72, 73, 73, 73, 73, 73, 74, 74, 74, 91, 91, 71, 71, 72, 72, 72, 72, 73, 73, 73, 73, 90, 74, 74, 74, 91, 91, 71, 71, 72, 72, 72, 89, 89, 73, 73, 90, 90, 74, 74, 91, 91,108, 88, 88, 88, 89, 89, 89,106, 73, 90, 90, 90,107, 74, 91,108,108, 75, 75, 76, 76, 76, 76,106, 77, 77, 77,107, 78, 78, 78,108,125, 75, 75, 76, 76, 76, 76, 77, 77, 77, 77, 77, 78, 78, 78, 95, 95, 75, 75, 76, 76, 76, 93, 93, 77, 77, 94, 94, 78, 78, 95, 95, 95, 92, 92, 93, 93, 93, 93,110, 94, 94, 94,111,111, 95, 95, 95, 96, 109,109,109,110,110,110,110, 94, 94,111,111,112, 95, 95, 96, 96, 79, 79, 64, 64, 64, 81, 81, 65, 65, 82, 99, 99, 66, 83,100,100, 79, 79, 51, 64, 64, 81, 81, 65, 65, 82, 99, 99, 66, 83,100,100, 67, 51, 51, 51, 68, 68, 69, 69, 69, 69, 86, 70, 70, 70, 87,104, 67, 67, 51, 68, 68, 68, 69, 69, 69, 69, 86, 70, 70, 70, 87,104, 67, 67, 68, 68, 68, 85, 85, 69, 69, 86, 86, 70, 70, 87,104,104, 84, 84, 68, 68, 85, 85, 85, 69, 69, 86,103,103, 70, 87,104,104, 84, 84, 72, 72, 85, 85, 85,102, 73, 86,103,120,120, 87,104,121, 71, 71, 72, 72, 72, 72,102, 73, 73, 73, 73, 74, 74, 74, 91,121, 71, 71, 72, 72, 72, 72, 73, 73, 73, 73, 90, 74, 74, 74, 91,108, 88, 88, 72, 72, 89, 89, 89, 73, 73, 90, 90, 74, 74, 91,108,108, 105,105, 89, 89, 89,106,106, 73, 90, 90,107,107, 91, 91,108,108, 105,105, 76, 76, 76,106,123, 77, 77, 77,107,124, 78, 78,108,125, 75, 75, 76, 76, 76, 76,123, 77, 77, 77, 94, 78, 78, 78, 95,125, 92, 92, 76, 76, 93, 93, 93, 77, 77, 94, 94, 78, 78, 95, 95, 96, 109,109, 93, 93,110,110,110, 94, 94,111,111,111, 95, 95, 96, 96, 109,109,110,110,110,110,127,127,111,111,111,112,112, 96, 96, 96, 80, 80, 64, 64, 81, 81, 98, 98, 65, 82, 99,116,116, 83,100,117, 80, 80, 64, 64, 81, 81, 98, 98, 65, 82, 99,116,116, 83,100,117, 67, 67, 51, 68, 68, 68, 98, 69, 69, 69, 99, 70, 70, 70, 87,104, 67, 67, 68, 68, 68, 85, 85, 69, 69, 86, 86, 70, 70, 87, 87,104, 84, 84, 68, 68, 85, 85, 85, 69, 69, 86,103,103, 70, 87,104,104, 84, 84, 68, 85, 85, 85, 85,102, 86, 86,103,120,120, 87,104,121, 101,101,101, 85, 85, 85,102,102, 86,103,103,120,120,120,104,121, 101,101, 72, 72, 72,102,102,102, 73, 73,120,120, 74, 74, 91,121, 71, 71, 72, 72, 72, 89, 89, 73, 73, 90, 90, 74, 74, 91, 91,108, 88, 88, 72, 89, 89, 89,106, 73, 90, 90, 90,107, 74, 91,108,108, 105,105,105, 89,106,106,106,123, 90, 90,107,107,124,108,108,125, 122,122, 76, 76,106,123,123,123, 77,107,107,124,124,124,125,125, 122,122, 76, 76, 76,123,123, 77, 77, 77,124,124,124, 78, 95,125, 92, 92, 76, 93, 93, 93,123, 77, 94, 94,111,124, 78, 95, 95, 96, 109,109, 93, 93,110,110,110, 94, 94,111,111,112, 95, 95, 96, 96, 126,126,110,110,110,127,127,127,111,111,112,112,112, 96, 96,113, 97, 97, 97,143, 81, 98, 98,115,115, 99, 99,116,116,116,100,117, 97, 97, 97,143, 81, 98, 98,115,115, 99, 99,116,116,116,100,117, 97, 97,131,131,131, 98, 98,115,132,132, 99,116,116,133,100,117, 130,130,131,131,131, 85, 85,132,132, 86,103,103,133, 87,104,104, 84, 84,131,131, 85, 85, 85,102,132, 86,103,120,120, 87,104,121, 101,101,101, 85, 85, 85,102,102, 86,103,103,120,120,120,104,121, 101,101,101, 85, 85,102,102,102,119,103,120,120,120,120,121,121, 118,118,118,135,102,102,102,119,119,119,120,120,120,137, 91,121, 118,118,135,135,135, 89,119,119,119, 90, 90,137,137, 91,108,108, 105,105,135, 89, 89,106,106,119, 90, 90,107,107,137, 91,108,108, 105,105,105,106,106,106,123,123, 90,107,107,124,124,108,108,125, 122,122,122,106,123,123,123,123,140,107,124,124,124,124,125,125, 122,122,122,139,123,123,123,123,140,140,124,124,124,124, 95,125, 122,122,139, 93, 93,123,123,140, 94, 94,111,124,124, 95, 95, 96, 109,109,109,110,110,110,127, 94,111,111,111,112, 95, 95, 96, 96, 126,126,126,110,127,127,127,127,111,111,112,112,112, 96, 96,113, 114,114,143,143,143, 98,115,115,115,128,116,129,129,129,146,117, 114,114,143,143,143, 98,115,115,115,128,116,129,129,129,146,117, 130,130,131,131,131,131,115,132,132,132,132,133,133,133,133,150, 130,130,131,131,131,131,132,132,132,132,132,133,133,133,150,150, 130,130,131,131,131,131,102,132,132,132,103,133,133,133,150,121, 101,101,131,131,131,102,102,102,132,132,120,120,133,133,150,121, 118,118,118,135,102,102,102,119,119,119,120,120,120,137,150,121, 118,118,135,135,135,102,119,119,119,136,136,137,137,137,137,154, 118,118,135,135,135,135,119,119,136,136,136,137,137,137,154,154, 134,134,135,135,135,135,119,136,136,136,153,137,137,137,154,154, 122,122,135,135,106,123,123,136,136,153,107,124,124,154,154,125, 138,138,139,139,139,123,123,140,140,140,124,124,141,141,141,125, 138,138,139,139,139,139,123,140,140,140,124,141,141,141,141,158, 138,138,139,139,139,139,140,140,140,140,157,141,141,141,158,158, 155,155,139,156,156,156,156,140,157,157,157,141,141,158,158,158, 126,126,156,156,127,127,127,157,157,157,112,112,158,158,158,113, 142,142,143,143,143,143,115,115,128,128,145,129,129,129,146,163, 142,142,143,143,143,143,115,115,128,128,145,129,129,129,146,163, 130,130,131,131,131,131,132,132,132,132,132,133,133,133,150,150, 130,130,131,131,131,131,132,132,132,132,149,133,133,133,150,150, 130,130,131,131,131,131,132,132,132,132,149,133,133,133,150,167, 130,130,131,131,131,148,148,132,132,149,149,133,133,150,150,167, 118,118,135,135,135,148,119,119,119,149,149,137,137,150,167,167, 118,118,135,135,135,135,119,119,136,136,136,137,137,137,154,154, 134,134,135,135,135,135,119,136,136,136,153,137,137,137,154,154, 134,134,135,135,135,152,152,136,136,153,153,137,137,154,154,171, 151,151,135,152,152,152,152,136,153,153,153,137,137,154,171,171, 138,138,139,139,139,139,140,140,140,140,140,141,141,141,141,171, 138,138,139,139,139,139,140,140,140,140,140,141,141,141,158,158, 138,138,139,139,139,156,156,140,140,157,157,141,141,158,158,158, 155,155,156,156,156,156,173,157,157,157,174,141,158,158,158,175, 172,172,156,156,173,173,173,157,157,174,174,174,158,158,175,175, 159,159,143,143,144,144,161,128,128,145,145,162,129,146,163,163, 159,159,143,143,144,144,161,128,128,145,145,162,129,146,163,163, 130,130,131,131,131,131,132,132,132,132,149,133,133,150,150,163, 130,130,131,131,131,148,148,132,132,149,149,133,133,150,150,167, 147,147,131,131,148,148,148,132,132,149,149,133,133,150,167,167, 147,147,131,148,148,148,165,132,149,149,149,166,133,150,167,167, 164,164,135,148,148,165,165,119,149,149,166,166,137,150,167,167, 134,134,135,135,135,135,119,136,136,136,153,137,137,137,154,154, 134,134,135,135,135,152,152,136,136,153,153,137,137,154,154,171, 151,151,135,152,152,152,152,136,153,153,153,137,137,154,171,171, 151,151,152,152,152,152,169,153,153,153,170,170,154,154,171,171, 168,168,139,139,139,169,169,140,140,140,170,170,141,141,171,188, 138,138,139,139,139,139,140,140,140,140,157,141,141,141,158,158, 155,155,156,156,156,156,156,140,157,157,157,141,141,158,158,175, 172,172,156,156,173,173,173,157,157,174,174,174,158,158,175,175, 172,172,172,173,173,173,173,157,174,174,174,191,158,175,175,175, 160,160,144,144,161,161,161,178,145,145,162,162,179,146,163,180, 160,160,144,144,161,161,161,178,145,145,162,162,179,146,163,180, 147,147,131,144,148,161,161,132,132,149,162,162,133,150,163,167, 147,147,147,148,148,148,165,132,149,149,149,166,133,150,167,167, 164,164,148,148,148,165,165,132,149,149,166,166,150,150,167,167, 164,164,164,148,165,165,165,182,149,149,166,166,183,167,167,184, 164,164,164,165,165,165,182,182,149,166,166,183,183,167,167,184, 181,181,135,135,135,182,182,136,136,153,166,183,183,154,154,184, 151,151,135,152,152,152,152,136,153,153,153,137,137,154,171,171, 151,151,152,152,152,152,169,153,153,153,170,170,154,154,171,171, 168,168,168,152,169,169,169,169,153,170,170,170,170,171,171,188, 168,168,168,169,169,169,186,186,140,170,170,170,187,187,188,188, 185,185,139,139,156,186,186,186,140,157,170,187,187,158,158,188, 155,155,156,156,156,173,173,157,157,157,174,187,158,158,158,175, 172,172,172,173,173,173,173,157,174,174,174,191,158,158,175,175, 189,189,173,173,173,190,190,190,174,174,191,191,191,175,175,176, 177,177,206,206,161,178,178,207,207,162,162,179,179,192,163,180, 177,177,206,206,161,178,178,207,207,162,162,179,179,192,163,180, 193,193,194,194,194,194,178,195,195,195,162,179,196,196,196,180, 193,193,194,194,194,194,165,195,195,195,166,196,196,196,167,184, 164,164,194,194,194,165,182,195,195,195,166,183,196,196,167,184, 181,181,194,194,165,182,182,182,195,166,166,183,183,183,184,184, 181,181,181,165,182,182,182,182,199,166,183,183,183,183,184,184, 197,197,198,198,198,182,182,199,199,199,183,183,200,200,200,184, 197,197,198,198,198,198,199,199,199,199,199,200,200,200,200,171, 168,168,198,198,198,169,169,199,199,199,170,170,200,200,171,188, 168,168,168,169,169,169,186,186,199,170,170,170,187,187,188,188, 185,185,185,202,186,186,186,186,203,170,170,187,187,187,188,188, 185,185,202,202,202,186,186,203,203,203,187,187,187,204,204,188, 201,201,202,202,202,186,186,203,203,203,187,187,204,204,175,175, 172,172,202,173,173,190,190,203,203,174,191,191,204,175,175,175, 189,189,189,190,190,190,190,190,174,191,191,191,191,175,175,176, 205,205,206,206,206,178,178,207,207,207,179,179,192,192,209,180, 205,205,206,206,206,178,178,207,207,207,179,179,192,192,209,180, 193,193,194,194,194,194,178,195,195,195,195,196,196,196,196,213, 193,193,194,194,194,194,195,195,195,195,195,196,196,196,213,213, 193,193,194,194,194,194,182,195,195,195,212,196,196,196,213,184, 181,181,194,194,194,182,182,195,195,195,183,183,183,196,213,184, 181,181,181,198,182,182,182,182,199,199,183,183,183,183,213,184, 197,197,198,198,198,198,182,199,199,199,183,200,200,200,200,217, 197,197,198,198,198,198,199,199,199,199,199,200,200,200,217,217, 197,197,198,198,198,198,199,199,199,199,216,200,200,200,217,217, 185,185,198,198,215,186,186,186,199,216,170,187,187,217,217,188, 185,185,202,202,202,186,186,203,203,203,187,187,187,204,204,188, 201,201,202,202,202,186,186,203,203,203,187,187,204,204,204,221, 201,201,202,202,202,202,186,203,203,203,220,204,204,204,221,221, 218,218,202,219,219,219,219,203,220,220,220,204,204,221,221,221, 189,189,219,219,190,190,190,220,220,220,191,191,221,221,221,176, 222,222,206,206,223,223,178,207,207,208,208,192,192,209,209,226, 222,222,206,206,223,223,178,207,207,208,208,192,192,209,209,226, 193,193,194,194,194,194,195,195,195,212,212,196,196,196,213,213, 193,193,194,194,194,211,211,195,195,212,212,196,196,213,213,213, 210,210,194,194,211,211,211,195,195,212,212,196,196,213,213,230, 210,210,194,211,211,211,182,195,212,212,229,183,196,213,213,230, 181,181,198,211,211,182,182,199,212,212,229,183,183,213,213,230, 197,197,198,198,198,198,199,199,199,199,216,200,200,200,217,217, 197,197,198,198,198,215,215,199,199,216,216,200,200,217,217,217, 214,214,215,215,215,215,215,199,216,216,216,200,200,217,217,234, 214,214,215,215,215,232,232,216,216,216,233,187,217,217,217,234, 201,201,202,202,202,186,186,203,203,203,187,187,204,204,234,234, 201,201,202,202,202,202,186,203,203,203,220,204,204,204,221,221, 218,218,202,219,219,219,219,203,220,220,220,204,204,221,221,221, 218,218,219,219,219,219,219,220,220,220,220,237,221,221,221,238, 235,235,219,219,236,236,236,220,220,237,237,237,221,221,238,238, 239,239,223,223,224,224,224,208,208,225,225,225,209,209,226,226, 239,239,223,223,224,224,224,208,208,225,225,225,209,209,226,226, 210,210,211,211,211,211,224,195,212,212,225,196,196,213,213,226, 210,210,211,211,211,211,228,212,212,212,229,229,213,213,213,230, 227,227,211,211,228,228,228,212,212,229,229,229,213,213,230,230, 227,227,211,211,228,228,228,212,212,229,229,246,213,213,230,230, 227,227,227,228,228,228,245,212,229,229,229,246,213,213,230,230, 214,214,198,215,215,215,215,199,216,216,216,200,200,217,217,217, 214,214,215,215,215,215,232,216,216,216,233,200,217,217,217,234, 231,231,215,215,232,232,232,216,216,233,233,233,217,217,234,234, 231,231,231,232,232,232,232,216,233,233,233,250,217,217,234,234, 231,231,202,232,232,249,249,203,203,233,250,250,204,234,234,234, 218,218,202,219,219,219,219,203,220,220,220,204,204,221,221,221, 218,218,219,219,219,219,219,220,220,220,220,237,221,221,221,238, 235,235,219,219,236,236,236,220,220,237,237,237,221,221,238,238, 235,235,235,236,236,236,236,220,237,237,237,237,221,238,238,238, 240,240,224,224,224,241,241,241,225,225,242,242,242,226,226,243, 240,240,224,224,224,241,241,241,225,225,242,242,242,226,226,243, 227,227,211,224,228,228,241,212,212,225,229,242,213,213,226,230, 227,227,227,228,228,228,228,212,212,229,229,246,213,213,230,230, 227,227,228,228,228,228,245,245,229,229,229,246,246,230,230,230, 244,244,228,228,228,245,245,245,229,229,246,246,246,230,230,247, 244,244,244,228,245,245,245,245,229,229,246,246,246,230,230,247, 244,244,215,215,245,245,245,216,216,216,246,246,217,217,217,247, 231,231,215,215,232,232,232,216,216,233,233,233,217,217,234,234, 231,231,231,232,232,232,232,216,233,233,233,250,217,234,234,234, 248,248,232,232,232,249,249,249,233,233,250,250,250,234,234,251, 248,248,248,249,249,249,249,249,233,250,250,250,250,234,234,251, 248,248,219,219,249,249,249,220,220,220,250,250,221,221,221,251, 235,235,219,219,236,236,236,220,220,237,237,237,221,221,238,238, 235,235,235,236,236,236,236,220,237,237,237,237,221,238,238,238, 252,252,236,236,236,253,253,253,237,237,254,254,254,238,238,255, }; /* * Convert an 8-bit rgb color into the index * of the `nearest' color in the rgbv color map. */ int rgbvindex(int r, int g, int b){ if(r<0) r=0; else if(255>4][g>>4][b>>4]; } /* * int clook(int r, int g, int b) * Return the index in the rgbv colormap of a color near (r,g,b). * guarantees to find the closest colormap entry * (`closest' in Euclidean distance in (r,g,b) space). * Before calling clook, you must initialize its data structures thus: * * uchar cmap[256][3]; * setrgbvmap(cmap); * initcindex(cmap, 256); */ /* * Remap an image from an arbitrary color map to rgbv. * Does Floyd-Steinberg, with error diffusion coefficients * * 1/4 * 3/8 3/8 */ void remaprgbv(void){ int *err, *errp, r, g, b, er, eg, eb, y, t; byte *p, *ep, *in, *out; byte rgbvmap[256][3]; err=malloc((image.wid+1)*3*sizeof(int)); memset(err, 0, (image.wid+1)*3*sizeof(int)); setmaprgbv(rgbvmap); p=image.image; for(y=0;y!=image.hgt;y++){ er=eg=eb=0; for(ep=p+image.wid,errp=err;p!=ep;p++,errp+=3){ in=image.cmap[*p]; r=in[0]+errp[0]; g=in[1]+errp[1]; b=in[2]+errp[2]; *p=rgbvindex(r, g, b); out=rgbvmap[*p]; r=in[0]-out[0]; t=3*r/8; errp[0]=t+er; errp[3]+=t; er=r-2*t; g=in[1]-out[1]; t=3*g/8; errp[1]=t+eg; errp[4]+=t; eg=g-2*t; b=in[2]-out[2]; t=3*b/8; errp[2]=t+eb; errp[5]+=t; eb=b-2*t; } } free(err); } /* * Remap an image from an arbitrary color map to rgbv, * with no error propagation or dithering -- fast but stupid. */ void lookuprgbv(void){ byte *p, *ep, *cm; int i; uchar map[256]; for(i=0;i!=256;i++){ cm=image.cmap[i]; map[i]=closest[cm[0]>>4][cm[1]>>4][cm[2]>>4]; } ep=image.image+image.wid*image.hgt; for(p=image.image;p!=ep;p++) *p=map[*p]; } . 341d 305a while(image.dy!=1 && image.dy>image.hgt){ image.dy>>=1; image.pass++; } . 301,302d 248,249c cur=finchar; if(imp) for(;;){ /* insertpixel(cur); */ *imp++=cur; if(imp==imerow){ imp+=(image.dy-1)*image.wid; imerow=imp+image.wid; if(imp>=imend){ if(image.pass<3){ imp = image.image+(4>>image.pass)*image.wid; imerow=imp+image.wid; image.dy=8>>image.pass; image.pass++; }else{ imp=0; if(outp!=out){ err(0, "GIF code overflows image"); outp=out; } break; } } } if(outp==out) break; cur=*--outp; } . 243c if(outp>&out[NOUT]) err(1, "GIF lzw code too long!"); . 234c /* insertpixel(finchar); */ if(imp) { *imp++=finchar; if(imp==imerow){ imp+=(image.dy-1)*image.wid; imerow=imp+image.wid; if(imp>=imend){ if(image.pass<3){ imp = image.image+(4>>image.pass)*image.wid; imerow=imp+image.wid; image.dy=8>>image.pass; image.pass++; }else imp=0; } } } else { err(0, "GIF code overflows image"); imp = 0; } . 217a imp=image.image; imerow=image.image+image.wid; imend=image.image+image.wid*image.hgt; . 208a byte *imp; /* image pointer */ byte *imerow; /* image end of row pointer */ byte *imend; /* image end of image pointer */ . 207c static byte out[NOUT+1]; /* output string buffer */ . 169a #define NOUT 4096 . 108,126d 50a byte ci9[3][765] = { { 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,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,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,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,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,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,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,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, 0,0,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32, 32,32,32,32,32,32,32,64,64,64,64,64,64,64,64,64, 64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64, 64,64,64,64,64,64,64,64,64,64,64,96,96,96,96,96, 96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96, 96,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, 128,128,128,128,160,160,160,160,160,160,160,160,160,160,160,160, 160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160, 160,160,160,160,160,160,160,160,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192, 192,192,192,192,192,192,192,192,192,192,192,192,192,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224,224,224,224, 224,224,224,224,224,224,224,224,224,224,224,224,224 }, { 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,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,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,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,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,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,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,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, 0,0,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,12,12,12,12,12, 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, 12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,20,20,20,20,20,20,20,20,20,20,20,20, 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20, 20,20,20,20,20,20,20,20,24,24,24,24,24,24,24,24, 24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24, 24,24,24,24,24,24,24,24,24,24,24,24,24,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28, 28,28,28,28,28,28,28,28,28,28,28,28,28 }, { 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,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,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,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,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,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,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,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, 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,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3,3,3,3,3,3 }, }; /* ordered dither table for red, green (8 quantization levels) */ int rgodither[16][16] = { { 18, -9, 11,-16, 16,-10, 9,-17, 17, -9, 10,-16, 16,-11, 9,-18}, { 0, 9, -6, 2, -1, 7, -8, 0, 0, 8, -7, 1, -2, 6, -9, 0}, { 13,-13, 15,-11, 11,-15, 14,-13, 13,-14, 15,-11, 11,-15, 13,-13}, { -4, 4, -2, 6, -6, 2, -4, 5, -5, 4, -2, 6, -6, 2, -4, 4}, { 17,-10, 10,-17, 17, -9, 10,-16, 16,-10, 9,-17, 17,-10, 10,-17}, { -1, 7, -8, 1, 0, 8, -7, 1, -1, 7, -8, 0, -1, 8, -7, 1}, { 12,-14, 14,-12, 13,-14, 15,-12, 12,-15, 14,-13, 12,-14, 14,-12}, { -5, 3, -3, 5, -5, 3, -2, 6, -6, 2, -3, 5, -5, 3, -3, 5}, { 17, -9, 11,-16, 16,-11, 9,-18, 18, -9, 11,-16, 16,-11, 9,-17}, { 0, 8, -7, 1, -2, 7, -8, 0, 0, 8, -7, 2, -1, 7, -8, 0}, { 13,-14, 15,-11, 11,-15, 13,-13, 13,-13, 15,-11, 11,-15, 14,-13}, { -4, 4, -2, 6, -6, 2, -4, 4, -4, 4, -2, 6, -6, 2, -4, 4}, { 16,-10, 9,-17, 17,-10, 10,-16, 16,-10, 10,-17, 17, -9, 10,-16}, { -1, 7, -8, 0, 0, 8, -7, 1, -1, 7, -8, 0, 0, 8, -7, 1}, { 12,-15, 14,-12, 12,-14, 15,-12, 12,-15, 14,-12, 12,-14, 15,-12}, { -6, 3, -3, 5, -5, 3, -3, 5, -5, 3, -3, 5, -5, 3, -3, 6}, }; /* ordered dither table for blue (4 quantization levels) */ int bodither[16][16] = { { 42,-21, 26,-37, 38,-25, 22,-41, 41,-22, 25,-38, 37,-26, 21,-42}, { 0, 21,-16, 5, -4, 17,-20, 1, -1, 20,-17, 4, -5, 16,-21, 0}, { 31,-32, 37,-26, 27,-36, 33,-30, 30,-33, 36,-27, 26,-37, 32,-31}, {-10, 10, -5, 15,-14, 6, -9, 11,-11, 9, -6, 14,-15, 5,-10, 10}, { 39,-24, 23,-40, 41,-22, 25,-38, 38,-25, 22,-41, 40,-23, 24,-39}, { -2, 18,-18, 2, -1, 19,-17, 3, -3, 17,-19, 1, -2, 18,-18, 2}, { 29,-34, 34,-29, 30,-33, 35,-28, 28,-35, 33,-30, 29,-34, 34,-29}, {-13, 7, -8, 13,-12, 9, -6, 14,-14, 6, -9, 12,-13, 8, -7, 13}, { 41,-22, 25,-38, 37,-26, 21,-42, 42,-21, 26,-37, 38,-25, 22,-41}, { 0, 20,-16, 4, -4, 16,-20, 0, 0, 20,-16, 4, -4, 16,-20, 0}, { 31,-32, 36,-27, 27,-36, 32,-31, 31,-32, 36,-27, 27,-36, 32,-31}, {-11, 9, -6, 15,-15, 5,-10, 11,-11, 10, -5, 15,-15, 6, -9, 11}, { 39,-24, 23,-40, 40,-23, 24,-39, 39,-24, 23,-40, 40,-23, 24,-39}, { -3, 17,-19, 1, -2, 19,-18, 3, -3, 18,-19, 2, -1, 19,-17, 3}, { 28,-35, 33,-30, 29,-34, 35,-28, 28,-35, 34,-29, 30,-33, 35,-28}, {-14, 7, -8, 12,-12, 8, -7, 13,-13, 7, -8, 12,-12, 8, -7, 14}, }; . 31,34d 27a int dy; int pass; . 25a byte *image; . 6d wq //GO.SYSIN DD VADIM gif2pic.c sum=`{sum < 836422821/gif2pic.c} if(~ bda00ee240259 $sum(1)^$sum(2)) echo if not{ echo 836422821/gif2pic.c checksum error creating updated file exit checksum } target=836422821/halftone.c echo -n '836422821/halftone.c: ' if(! test -f $srcdir/halftone.c || ! test -r $srcdir/halftone.c){ echo $srcdir/halftone.c unreadable exit unreadable } sum=`{sum < $srcdir/halftone.c} if(! ~ 0978a1532468 $sum(1)^$sum(2)){ echo $srcdir/halftone.c is not the original distribution file exit original } cp $srcdir/halftone.c 836422821/halftone.c ed 836422821/halftone.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM halftone.c' 19d wq //GO.SYSIN DD VADIM halftone.c sum=`{sum < 836422821/halftone.c} if(~ 86955eaf2450 $sum(1)^$sum(2)) echo if not{ echo 836422821/halftone.c checksum error creating updated file exit checksum } target=836422821/he.c echo -n '836422821/he.c: ' if(! test -f $srcdir/he.c || ! test -r $srcdir/he.c){ echo $srcdir/he.c unreadable exit unreadable } sum=`{sum < $srcdir/he.c} if(! ~ bd9b56901434 $sum(1)^$sum(2)){ echo $srcdir/he.c is not the original distribution file exit original } cp $srcdir/he.c 836422821/he.c ed 836422821/he.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM he.c' 7d wq //GO.SYSIN DD VADIM he.c sum=`{sum < 836422821/he.c} if(~ a5eb6ac51416 $sum(1)^$sum(2)) echo if not{ echo 836422821/he.c checksum error creating updated file exit checksum } target=836422821/hist.c echo -n '836422821/hist.c: ' if(! test -f $srcdir/hist.c || ! test -r $srcdir/hist.c){ echo $srcdir/hist.c unreadable exit unreadable } sum=`{sum < $srcdir/hist.c} if(! ~ cf824fdf920 $sum(1)^$sum(2)){ echo $srcdir/hist.c is not the original distribution file exit original } cp $srcdir/hist.c 836422821/hist.c ed 836422821/hist.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM hist.c' 6d wq //GO.SYSIN DD VADIM hist.c sum=`{sum < 836422821/hist.c} if(~ f7967956902 $sum(1)^$sum(2)) echo if not{ echo 836422821/hist.c checksum error creating updated file exit checksum } target=836422821/hysteresis.c echo -n '836422821/hysteresis.c: ' if(! test -f $srcdir/hysteresis.c || ! test -r $srcdir/hysteresis.c){ echo $srcdir/hysteresis.c unreadable exit unreadable } sum=`{sum < $srcdir/hysteresis.c} if(! ~ 20ea6aab1784 $sum(1)^$sum(2)){ echo $srcdir/hysteresis.c is not the original distribution file exit original } cp $srcdir/hysteresis.c 836422821/hysteresis.c ed 836422821/hysteresis.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM hysteresis.c' 58c void filter(unsigned char *l0, unsigned char *l1, unsigned char *l2, int nchan, int npix){ . 24c void filter(unsigned char *, unsigned char *, unsigned char *, int, int); . 6d wq //GO.SYSIN DD VADIM hysteresis.c sum=`{sum < 836422821/hysteresis.c} if(~ 877a72b41776 $sum(1)^$sum(2)) echo if not{ echo 836422821/hysteresis.c checksum error creating updated file exit checksum } target=836422821/improve.c echo -n '836422821/improve.c: ' if(! test -f $srcdir/improve.c || ! test -r $srcdir/improve.c){ echo $srcdir/improve.c unreadable exit unreadable } sum=`{sum < $srcdir/improve.c} if(! ~ 9c1af2995154 $sum(1)^$sum(2)){ echo $srcdir/improve.c is not the original distribution file exit original } cp $srcdir/improve.c 836422821/improve.c ed 836422821/improve.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM improve.c' 7d wq //GO.SYSIN DD VADIM improve.c sum=`{sum < 836422821/improve.c} if(~ 5ab3ad695136 $sum(1)^$sum(2)) echo if not{ echo 836422821/improve.c checksum error creating updated file exit checksum } target=836422821/logo.c echo -n '836422821/logo.c: ' if(! test -f $srcdir/logo.c || ! test -r $srcdir/logo.c){ echo $srcdir/logo.c unreadable exit unreadable } sum=`{sum < $srcdir/logo.c} if(! ~ ff2a6c251541 $sum(1)^$sum(2)){ echo $srcdir/logo.c is not the original distribution file exit original } cp $srcdir/logo.c 836422821/logo.c ed 836422821/logo.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM logo.c' 5d wq //GO.SYSIN DD VADIM logo.c sum=`{sum < 836422821/logo.c} if(~ aebd4d891523 $sum(1)^$sum(2)) echo if not{ echo 836422821/logo.c checksum error creating updated file exit checksum } target=836422821/lum.c echo -n '836422821/lum.c: ' if(! test -f $srcdir/lum.c || ! test -r $srcdir/lum.c){ echo $srcdir/lum.c unreadable exit unreadable } sum=`{sum < $srcdir/lum.c} if(! ~ 12af9da81651 $sum(1)^$sum(2)){ echo $srcdir/lum.c is not the original distribution file exit original } cp $srcdir/lum.c 836422821/lum.c ed 836422821/lum.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM lum.c' 6d wq //GO.SYSIN DD VADIM lum.c sum=`{sum < 836422821/lum.c} if(~ 3f2db7901633 $sum(1)^$sum(2)) echo if not{ echo 836422821/lum.c checksum error creating updated file exit checksum } target=836422821/map.cc echo -n '836422821/map.cc: ' if(! test -f $srcdir/map.cc || ! test -r $srcdir/map.cc){ echo $srcdir/map.cc unreadable exit unreadable } sum=`{sum < $srcdir/map.cc} if(! ~ 4dc5a73a3287 $sum(1)^$sum(2)){ echo $srcdir/map.cc is not the original distribution file exit original } cp $srcdir/map.cc 836422821/map.cc ed 836422821/map.cc >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM map.cc' 3d wq //GO.SYSIN DD VADIM map.cc sum=`{sum < 836422821/map.cc} if(~ 383f6bdb3269 $sum(1)^$sum(2)) echo if not{ echo 836422821/map.cc checksum error creating updated file exit checksum } target=836422821/mcut.c echo -n '836422821/mcut.c: ' if(! test -f $srcdir/mcut.c || ! test -r $srcdir/mcut.c){ echo $srcdir/mcut.c unreadable exit unreadable } sum=`{sum < $srcdir/mcut.c} if(! ~ d38101eb4166 $sum(1)^$sum(2)){ echo $srcdir/mcut.c is not the original distribution file exit original } cp $srcdir/mcut.c 836422821/mcut.c ed 836422821/mcut.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM mcut.c' 6d wq //GO.SYSIN DD VADIM mcut.c sum=`{sum < 836422821/mcut.c} if(~ 2ee817b14148 $sum(1)^$sum(2)) echo if not{ echo 836422821/mcut.c checksum error creating updated file exit checksum } target=836422821/median.c echo -n '836422821/median.c: ' if(! test -f $srcdir/median.c || ! test -r $srcdir/median.c){ echo $srcdir/median.c unreadable exit unreadable } sum=`{sum < $srcdir/median.c} if(! ~ 912a58fd1772 $sum(1)^$sum(2)){ echo $srcdir/median.c is not the original distribution file exit original } cp $srcdir/median.c 836422821/median.c ed 836422821/median.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM median.c' 6d wq //GO.SYSIN DD VADIM median.c sum=`{sum < 836422821/median.c} if(~ e7fef21c1754 $sum(1)^$sum(2)) echo if not{ echo 836422821/median.c checksum error creating updated file exit checksum } target=836422821/mkfile echo -n '836422821/mkfile: ' if(! test -f $srcdir/mkfile || ! test -r $srcdir/mkfile){ echo $srcdir/mkfile unreadable exit unreadable } sum=`{sum < $srcdir/mkfile} if(! ~ 179e7ebc1352 $sum(1)^$sum(2)){ echo $srcdir/mkfile is not the original distribution file exit original } cp $srcdir/mkfile 836422821/mkfile ed 836422821/mkfile >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM mkfile' 93,97c all:V: dpic-all jpg2pic-all install:V: dpic-install jpg2pic-install installall:V: dpic-installall jpg2pic-installall clean:V: dpic-clean jpg2pic-clean nuke:V: dpic-nuke jpg2pic-nuke . 87a ikon.$O: scsicam.h . 74a twb.r\ . 56a scale\ . 42a paint\ . 40a mugs\ . 31a ikon\ . 21a enc2bit\ . 8a bit2enc\ . wq //GO.SYSIN DD VADIM mkfile sum=`{sum < 836422821/mkfile} if(~ e6da3c521488 $sum(1)^$sum(2)) echo if not{ echo 836422821/mkfile checksum error creating updated file exit checksum } target=836422821/nasa2pic.c echo -n '836422821/nasa2pic.c: ' if(! test -f $srcdir/nasa2pic.c || ! test -r $srcdir/nasa2pic.c){ echo $srcdir/nasa2pic.c unreadable exit unreadable } sum=`{sum < $srcdir/nasa2pic.c} if(! ~ 510159035422 $sum(1)^$sum(2)){ echo $srcdir/nasa2pic.c is not the original distribution file exit original } cp $srcdir/nasa2pic.c 836422821/nasa2pic.c ed 836422821/nasa2pic.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM nasa2pic.c' 3d wq //GO.SYSIN DD VADIM nasa2pic.c sum=`{sum < 836422821/nasa2pic.c} if(~ e61cd3705404 $sum(1)^$sum(2)) echo if not{ echo 836422821/nasa2pic.c checksum error creating updated file exit checksum } target=836422821/nohed.r echo -n '836422821/nohed.r: ' if(! test -f $srcdir/nohed.r || ! test -r $srcdir/nohed.r){ echo $srcdir/nohed.r unreadable exit unreadable } sum=`{sum < $srcdir/nohed.r} if(! ~ 87e32c7c117 $sum(1)^$sum(2)){ echo $srcdir/nohed.r is not the original distribution file exit original } cp $srcdir/nohed.r 836422821/nohed.r ed 836422821/nohed.r >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM nohed.r' 2a if(! ~ $#* 2){ echo Usage: $0 picfile >/fd/2 exits usage } . wq //GO.SYSIN DD VADIM nohed.r sum=`{sum < 836422821/nohed.r} if(~ 1abb6a0e178 $sum(1)^$sum(2)) echo if not{ echo 836422821/nohed.r checksum error creating updated file exit checksum } target=836422821/pcp.c echo -n '836422821/pcp.c: ' if(! test -f $srcdir/pcp.c || ! test -r $srcdir/pcp.c){ echo $srcdir/pcp.c unreadable exit unreadable } sum=`{sum < $srcdir/pcp.c} if(! ~ 3336e9608389 $sum(1)^$sum(2)){ echo $srcdir/pcp.c is not the original distribution file exit original } cp $srcdir/pcp.c 836422821/pcp.c ed 836422821/pcp.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM pcp.c' 134c fprint(2, "%s: %s short: %r (last y=%d)\n", argv[0], in.name, y-1); . 126a if(out.pf==0){ fprint(2, "%s: %s: %r\n", argv[0], out.name); exits("picopen_w"); } . 108a else if(in.pf->cmap && strchr(in.chan, 'm')!=0 && strchr(out.chan, 'm')!=0){ needcmap=1; cmap=in.pf->cmap; } . 104c else if(flag['m']){ . wq //GO.SYSIN DD VADIM pcp.c sum=`{sum < 836422821/pcp.c} if(~ 7462f9e18602 $sum(1)^$sum(2)) echo if not{ echo 836422821/pcp.c checksum error creating updated file exit checksum } target=836422821/pcx2pic.c echo -n '836422821/pcx2pic.c: ' if(! test -f $srcdir/pcx2pic.c || ! test -r $srcdir/pcx2pic.c){ echo $srcdir/pcx2pic.c unreadable exit unreadable } sum=`{sum < $srcdir/pcx2pic.c} if(! ~ 24fa2bd84689 $sum(1)^$sum(2)){ echo $srcdir/pcx2pic.c is not the original distribution file exit original } cp $srcdir/pcx2pic.c 836422821/pcx2pic.c ed 836422821/pcx2pic.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM pcx2pic.c' 211,223c fprint(1, "manufacturer = %d\n", h->manufacturer); fprint(1, "version = %d\n", h->version); fprint(1, "encoding = %d\n", h->encoding); fprint(1, "bits2pixel = %d\n", h->bits2pixel); fprint(1, "xmin = %d\n", h->xmin); fprint(1, "ymin = %d\n", h->ymin); fprint(1, "xmax = %d\n", h->xmax); fprint(1, "ymax = %d\n", h->ymax); fprint(1, "hres = %d\n", h->hres); fprint(1, "vres = %d\n", h->vres); fprint(1, "nplanes = %d\n", h->nplanes); fprint(1, "bytes2line = %d\n", h->bytes2line); fprint(1, "pallette = %d\n", h->pallette); . 209c pcxhdump(Pcxhdr *h) . 146c fprint(2, "unexpected eof y=%d, x=%d\n", y, x); . 141a picwrite(out, line); . 135,140c if(h->bits2pixel==1){ for(i=0;i!=n;i++) for(j=128;j!=0;j>>=1) *lp++=c&j?255:0; } else{ for(i=0;i!=n;i++) *lp++=c; } . 105,124c for(y=h->ymin; y<=h->ymax; y++){ lp=line; for(x=0; xbytes2line; x+=n){ . 103a line=malloc(h->ymax-h->ymin+1+7); out=picopen_w("OUT", h->bits2pixel==1?"bitmap":"runcode", h->xmin, h->ymin, h->xmax-h->xmin+1, h->ymax-h->ymin+1, "m", 0, h->cmap); picputprop(out, "NAME", name?name:argv[0]); . 102c else . 97,100c if(debug){ pcxhdump(h); exits(0); } if(h->bits2pixel == 1) . 93,94d 77,79d 67,68c int c, x, y, i, j, n; char *name=0, *line, *lp; PICFILE *out; . 61,62d 59d 53c void pcxhdump(Pcxhdr*); . 49c char * cmap; /* might point to a long one */ . 43c char colormap[48]; . 3a #include . wq //GO.SYSIN DD VADIM pcx2pic.c sum=`{sum < 836422821/pcx2pic.c} if(~ d4f7a76d4362 $sum(1)^$sum(2)) echo if not{ echo 836422821/pcx2pic.c checksum error creating updated file exit checksum } target=836422821/pdup.c echo -n '836422821/pdup.c: ' if(! test -f $srcdir/pdup.c || ! test -r $srcdir/pdup.c){ echo $srcdir/pdup.c unreadable exit unreadable } sum=`{sum < $srcdir/pdup.c} if(! ~ 4c89901d1282 $sum(1)^$sum(2)){ echo $srcdir/pdup.c is not the original distribution file exit original } cp $srcdir/pdup.c 836422821/pdup.c ed 836422821/pdup.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM pdup.c' 3d wq //GO.SYSIN DD VADIM pdup.c sum=`{sum < 836422821/pdup.c} if(~ 56bddeb51264 $sum(1)^$sum(2)) echo if not{ echo 836422821/pdup.c checksum error creating updated file exit checksum } target=836422821/pic2gif.c echo -n '836422821/pic2gif.c: ' if(! test -f $srcdir/pic2gif.c || ! test -r $srcdir/pic2gif.c){ echo $srcdir/pic2gif.c unreadable exit unreadable } sum=`{sum < $srcdir/pic2gif.c} if(! ~ 6787b5b216500 $sum(1)^$sum(2)){ echo $srcdir/pic2gif.c is not the original distribution file exit original } cp $srcdir/pic2gif.c 836422821/pic2gif.c ed 836422821/pic2gif.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM pic2gif.c' 11d wq //GO.SYSIN DD VADIM pic2gif.c sum=`{sum < 836422821/pic2gif.c} if(~ 70fac19d16482 $sum(1)^$sum(2)) echo if not{ echo 836422821/pic2gif.c checksum error creating updated file exit checksum } target=836422821/pic2ps.c echo -n '836422821/pic2ps.c: ' if(! test -f $srcdir/pic2ps.c || ! test -r $srcdir/pic2ps.c){ echo $srcdir/pic2ps.c unreadable exit unreadable } sum=`{sum < $srcdir/pic2ps.c} if(! ~ e3e351012305 $sum(1)^$sum(2)){ echo $srcdir/pic2ps.c is not the original distribution file exit original } cp $srcdir/pic2ps.c 836422821/pic2ps.c ed 836422821/pic2ps.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM pic2ps.c' 15d wq //GO.SYSIN DD VADIM pic2ps.c sum=`{sum < 836422821/pic2ps.c} if(~ ebaa9b712287 $sum(1)^$sum(2)) echo if not{ echo 836422821/pic2ps.c checksum error creating updated file exit checksum } target=836422821/piccat.c echo -n '836422821/piccat.c: ' if(! test -f $srcdir/piccat.c || ! test -r $srcdir/piccat.c){ echo $srcdir/piccat.c unreadable exit unreadable } sum=`{sum < $srcdir/piccat.c} if(! ~ 0f7a41771267 $sum(1)^$sum(2)){ echo $srcdir/piccat.c is not the original distribution file exit original } cp $srcdir/piccat.c 836422821/piccat.c ed 836422821/piccat.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM piccat.c' 6d wq //GO.SYSIN DD VADIM piccat.c sum=`{sum < 836422821/piccat.c} if(~ f9cbc92f1249 $sum(1)^$sum(2)) echo if not{ echo 836422821/piccat.c checksum error creating updated file exit checksum } target=836422821/picjoin.c echo -n '836422821/picjoin.c: ' if(! test -f $srcdir/picjoin.c || ! test -r $srcdir/picjoin.c){ echo $srcdir/picjoin.c unreadable exit unreadable } sum=`{sum < $srcdir/picjoin.c} if(! ~ 909683861383 $sum(1)^$sum(2)){ echo $srcdir/picjoin.c is not the original distribution file exit original } cp $srcdir/picjoin.c 836422821/picjoin.c ed 836422821/picjoin.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM picjoin.c' 6d wq //GO.SYSIN DD VADIM picjoin.c sum=`{sum < 836422821/picjoin.c} if(~ 7c5fb3231365 $sum(1)^$sum(2)) echo if not{ echo 836422821/picjoin.c checksum error creating updated file exit checksum } target=836422821/ramp.c echo -n '836422821/ramp.c: ' if(! test -f $srcdir/ramp.c || ! test -r $srcdir/ramp.c){ echo $srcdir/ramp.c unreadable exit unreadable } sum=`{sum < $srcdir/ramp.c} if(! ~ 0306557a1945 $sum(1)^$sum(2)){ echo $srcdir/ramp.c is not the original distribution file exit original } cp $srcdir/ramp.c 836422821/ramp.c ed 836422821/ramp.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM ramp.c' 3d wq //GO.SYSIN DD VADIM ramp.c sum=`{sum < 836422821/ramp.c} if(~ cee5e08c1927 $sum(1)^$sum(2)) echo if not{ echo 836422821/ramp.c checksum error creating updated file exit checksum } target=836422821/remap.c echo -n '836422821/remap.c: ' if(! test -f $srcdir/remap.c || ! test -r $srcdir/remap.c){ echo $srcdir/remap.c unreadable exit unreadable } sum=`{sum < $srcdir/remap.c} if(! ~ 927ceb232120 $sum(1)^$sum(2)){ echo $srcdir/remap.c is not the original distribution file exit original } cp $srcdir/remap.c 836422821/remap.c ed 836422821/remap.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM remap.c' 6d wq //GO.SYSIN DD VADIM remap.c sum=`{sum < 836422821/remap.c} if(~ d33329712102 $sum(1)^$sum(2)) echo if not{ echo 836422821/remap.c checksum error creating updated file exit checksum } target=836422821/resample.c echo -n '836422821/resample.c: ' if(! test -f $srcdir/resample.c || ! test -r $srcdir/resample.c){ echo $srcdir/resample.c unreadable exit unreadable } sum=`{sum < $srcdir/resample.c} if(! ~ f44e8ada4577 $sum(1)^$sum(2)){ echo $srcdir/resample.c is not the original distribution file exit original } cp $srcdir/resample.c 836422821/resample.c ed 836422821/resample.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM resample.c' 13d wq //GO.SYSIN DD VADIM resample.c sum=`{sum < 836422821/resample.c} if(~ 6707800e4559 $sum(1)^$sum(2)) echo if not{ echo 836422821/resample.c checksum error creating updated file exit checksum } target=836422821/rotate.c echo -n '836422821/rotate.c: ' if(! test -f $srcdir/rotate.c || ! test -r $srcdir/rotate.c){ echo $srcdir/rotate.c unreadable exit unreadable } sum=`{sum < $srcdir/rotate.c} if(! ~ 052f03a81688 $sum(1)^$sum(2)){ echo $srcdir/rotate.c is not the original distribution file exit original } cp $srcdir/rotate.c 836422821/rotate.c ed 836422821/rotate.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM rotate.c' 9d wq //GO.SYSIN DD VADIM rotate.c sum=`{sum < 836422821/rotate.c} if(~ 6d398d051670 $sum(1)^$sum(2)) echo if not{ echo 836422821/rotate.c checksum error creating updated file exit checksum } target=836422821/save.c echo -n '836422821/save.c: ' if(! test -f $srcdir/save.c || ! test -r $srcdir/save.c){ echo $srcdir/save.c unreadable exit unreadable } sum=`{sum < $srcdir/save.c} if(! ~ ca73aabe491 $sum(1)^$sum(2)){ echo $srcdir/save.c is not the original distribution file exit original } cp $srcdir/save.c 836422821/save.c ed 836422821/save.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM save.c' 11c "m", argv, (char *)cmap); . 8a rdcolmap(&screen, rgbmap); for(i=0;i!=256;i++){ cmap[i][0]=rgbmap[255-i].red>>24; cmap[i][1]=rgbmap[255-i].green>>24; cmap[i][2]=rgbmap[255-i].blue>>24; } . 6a RGB rgbmap[256]; uchar cmap[256][3]; int i; . wq //GO.SYSIN DD VADIM save.c sum=`{sum < 836422821/save.c} if(~ 531a10cb713 $sum(1)^$sum(2)) echo if not{ echo 836422821/save.c checksum error creating updated file exit checksum } target=836422821/sgi2pic.c echo -n '836422821/sgi2pic.c: ' if(! test -f $srcdir/sgi2pic.c || ! test -r $srcdir/sgi2pic.c){ echo $srcdir/sgi2pic.c unreadable exit unreadable } sum=`{sum < $srcdir/sgi2pic.c} if(! ~ 1c8d84715853 $sum(1)^$sum(2)){ echo $srcdir/sgi2pic.c is not the original distribution file exit original } cp $srcdir/sgi2pic.c 836422821/sgi2pic.c ed 836422821/sgi2pic.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM sgi2pic.c' 6d wq //GO.SYSIN DD VADIM sgi2pic.c sum=`{sum < 836422821/sgi2pic.c} if(~ 9fac918a5835 $sum(1)^$sum(2)) echo if not{ echo 836422821/sgi2pic.c checksum error creating updated file exit checksum } target=836422821/shadepic.c echo -n '836422821/shadepic.c: ' if(! test -f $srcdir/shadepic.c || ! test -r $srcdir/shadepic.c){ echo $srcdir/shadepic.c unreadable exit unreadable } sum=`{sum < $srcdir/shadepic.c} if(! ~ 146bc7dd1955 $sum(1)^$sum(2)){ echo $srcdir/shadepic.c is not the original distribution file exit original } cp $srcdir/shadepic.c 836422821/shadepic.c ed 836422821/shadepic.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM shadepic.c' 6d wq //GO.SYSIN DD VADIM shadepic.c sum=`{sum < 836422821/shadepic.c} if(~ 2f9e44981937 $sum(1)^$sum(2)) echo if not{ echo 836422821/shadepic.c checksum error creating updated file exit checksum } target=836422821/sub.c echo -n '836422821/sub.c: ' if(! test -f $srcdir/sub.c || ! test -r $srcdir/sub.c){ echo $srcdir/sub.c unreadable exit unreadable } sum=`{sum < $srcdir/sub.c} if(! ~ 26515dc21142 $sum(1)^$sum(2)){ echo $srcdir/sub.c is not the original distribution file exit original } cp $srcdir/sub.c 836422821/sub.c ed 836422821/sub.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM sub.c' 6d wq //GO.SYSIN DD VADIM sub.c sum=`{sum < 836422821/sub.c} if(~ 27d1d3d61124 $sum(1)^$sum(2)) echo if not{ echo 836422821/sub.c checksum error creating updated file exit checksum } target=836422821/targa2pic.c echo -n '836422821/targa2pic.c: ' if(! test -f $srcdir/targa2pic.c || ! test -r $srcdir/targa2pic.c){ echo $srcdir/targa2pic.c unreadable exit unreadable } sum=`{sum < $srcdir/targa2pic.c} if(! ~ ab4b0a3a4199 $sum(1)^$sum(2)){ echo $srcdir/targa2pic.c is not the original distribution file exit original } cp $srcdir/targa2pic.c 836422821/targa2pic.c ed 836422821/targa2pic.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM targa2pic.c' 3d wq //GO.SYSIN DD VADIM targa2pic.c sum=`{sum < 836422821/targa2pic.c} if(~ f700ea344181 $sum(1)^$sum(2)) echo if not{ echo 836422821/targa2pic.c checksum error creating updated file exit checksum } target=836422821/tiff2pic.c echo -n '836422821/tiff2pic.c: ' if(! test -f $srcdir/tiff2pic.c || ! test -r $srcdir/tiff2pic.c){ echo $srcdir/tiff2pic.c unreadable exit unreadable } sum=`{sum < $srcdir/tiff2pic.c} if(! ~ e01c4e372725 $sum(1)^$sum(2)){ echo $srcdir/tiff2pic.c is not the original distribution file exit original } cp $srcdir/tiff2pic.c 836422821/tiff2pic.c ed 836422821/tiff2pic.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM tiff2pic.c' 105c if(!picwrite(out, outbuf)) goto BadWrite; . 92c if(!picwrite(out, outbuf)){ BadWrite: fprint(2, "OUT: %r (line %d), fd %d\n", y, out->fd); exits("picwrite"); } . 74c out=picopen_w("/fd/1", "runcode", 0, 0, nx, ny, chan, argv, 0); if(out==0){ fprint(2, "OUT: %r\n"); exits("open output"); } out->fd=1; /* this patches an ape/libc mismatch */ . 56a TIFFGetField(in, TIFFTAG_PHOTOMETRIC, &cspace); if(cspace==PHOTOMETRIC_MINISWHITE) bitflip=~0; else bitflip=0; . 52,53c if(!TIFFGetField(in, TIFFTAG_BITSPERSAMPLE, &nbit)) nbit=1; if(!TIFFGetField(in, TIFFTAG_SAMPLESPERPIXEL, &nchan)) nchan=1; . 42c ushort c, nchan, nbit, config, cspace; . 33c *outbuf=(((inp>>shift)&mask)*mul)^bitflip; . 14a char bitflip; . 6d wq //GO.SYSIN DD VADIM tiff2pic.c sum=`{sum < 836422821/tiff2pic.c} if(~ 0e82f6433117 $sum(1)^$sum(2)) echo if not{ echo 836422821/tiff2pic.c checksum error creating updated file exit checksum } target=836422821/transpose.c echo -n '836422821/transpose.c: ' if(! test -f $srcdir/transpose.c || ! test -r $srcdir/transpose.c){ echo $srcdir/transpose.c unreadable exit unreadable } sum=`{sum < $srcdir/transpose.c} if(! ~ 83d253dd2981 $sum(1)^$sum(2)){ echo $srcdir/transpose.c is not the original distribution file exit original } cp $srcdir/transpose.c 836422821/transpose.c ed 836422821/transpose.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM transpose.c' 16d wq //GO.SYSIN DD VADIM transpose.c sum=`{sum < 836422821/transpose.c} if(~ f49b39532963 $sum(1)^$sum(2)) echo if not{ echo 836422821/transpose.c checksum error creating updated file exit checksum } target=836422821/utah2pic.c echo -n '836422821/utah2pic.c: ' if(! test -f $srcdir/utah2pic.c || ! test -r $srcdir/utah2pic.c){ echo $srcdir/utah2pic.c unreadable exit unreadable } sum=`{sum < $srcdir/utah2pic.c} if(! ~ 6ae456505994 $sum(1)^$sum(2)){ echo $srcdir/utah2pic.c is not the original distribution file exit original } cp $srcdir/utah2pic.c 836422821/utah2pic.c ed 836422821/utah2pic.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM utah2pic.c' 26d wq //GO.SYSIN DD VADIM utah2pic.c sum=`{sum < 836422821/utah2pic.c} if(~ 203c9e9c5976 $sum(1)^$sum(2)) echo if not{ echo 836422821/utah2pic.c checksum error creating updated file exit checksum } target=836422821/xpand.c echo -n '836422821/xpand.c: ' if(! test -f $srcdir/xpand.c || ! test -r $srcdir/xpand.c){ echo $srcdir/xpand.c unreadable exit unreadable } sum=`{sum < $srcdir/xpand.c} if(! ~ 6e3c36632312 $sum(1)^$sum(2)){ echo $srcdir/xpand.c is not the original distribution file exit original } cp $srcdir/xpand.c 836422821/xpand.c ed 836422821/xpand.c >/dev/null >[2=1] <<'//GO.SYSIN DD VADIM xpand.c' 6d wq //GO.SYSIN DD VADIM xpand.c sum=`{sum < 836422821/xpand.c} if(~ 45a1b9322294 $sum(1)^$sum(2)) echo if not{ echo 836422821/xpand.c checksum error creating updated file exit checksum } target=836422821/bit2enc.c echo -n '836422821/bit2enc.c (new): ' cat > 836422821/bit2enc.c >[2]/dev/null <<'//GO.SYSIN DD VADIM /sys/src/fb' #include #include #include void writeimage(Rectangle, uchar *, int); int bytesperline(Rectangle r, int ld){ ulong ws, l, t; ws = 8>>ld; /* pixels per byte */ if(r.min.x >= 0){ l = (r.max.x+ws-1)/ws; l -= r.min.x/ws; }else{ /* make positive before divide */ t = (-r.min.x)+ws-1; t = (t/ws)*ws; l = (t+r.max.x+ws-1)/ws; } return l; } void main(int argc, char *argv[]){ int in, ldepth, bpl, ndata, offs, nread; uchar *data; Rectangle r; char hd[12*5]; if(argc!=2){ fprint(2, "Usage: %s bitmap\n", argv[0]); exits("usage"); } in=open(argv[1], OREAD); if(in==-1){ fprint(2, "%s: %r\n", argv[1]); exits("no open"); } offs=0; while(offs!=12*5 && (nread=read(in, hd+offs, 12*5-offs))>0) offs+=nread; if(offs!=12*5){ Short: fprint(2, "%s: %s short\n", argv[0], argv[1]); exits("short"); } ldepth=atoi(hd); r.min.x=atoi(hd+12); r.min.y=atoi(hd+24); r.max.x=atoi(hd+36); r.max.y=atoi(hd+48); bpl=bytesperline(r, ldepth); ndata=bpl*(r.max.y-r.min.y); data=malloc(ndata); if(data==0){ fprint(2, "No mem\n"); exits("no mem"); } offs=0; while(offs!=ndata && (nread=read(in, data+offs, ndata-offs))>0) offs+=nread; if(offs!=ndata) goto Short; print("compressed\n%11d %11d %11d %11d %11d ", ldepth, r.min.x, r.min.y, r.max.x, r.max.y); writeimage(r, data, bpl); /* * The input may be a font file, in which case there's extra * junk following the bitmap, which we just copy to the output */ while((nread=read(in, data, ndata))>0) write(1, data, nread); exits(0); } /* * These 5 definitions are copied from /usr/inferno/include/image.h */ #define NMATCH 3 /* shortest match possible */ #define NRUN (NMATCH+31) /* longest match possible */ #define NMEM 1024 /* window size */ #define NDUMP 128 /* maximum length of dump */ #define NCBLOCK 6000 /* size of compressed blocks */ #define HSHIFT 3 /* HSHIFT==5 runs slightly faster, but hash table is 64x bigger */ #define NHASH (1<<(HSHIFT*NMATCH)) #define HMASK (NHASH-1) #define hupdate(h, c) ((((h)<next){ for(s=p,t=hp->s;s!=es;s++,t++) if(*s!=*t) break; n=s-p; if(n>runlen){ runlen=n; q=hp->s; if(n==NRUN) break; } } if(runlen>8); *outp++=offs&255; } for(q=p+runlen;p!=q;p++){ if(cp->prev) cp->prev->next=0; cp->next=hash[h].next; cp->prev=&hash[h]; if(cp->next) cp->next->prev=cp; cp->prev->next=cp; cp->s=p; if(++cp==&chain[NMEM]) cp=chain; if(edata-p>=NMATCH) h=hupdate(h, p[NMATCH]); } } if(ndump!=0){ if(eout-outp 836422821/enc2bit.c >[2]/dev/null <<'//GO.SYSIN DD VADIM /sys/src/fb' #include #include #include /* * These 5 definitions are copied from /usr/inferno/include/image.h */ #define NMATCH 3 /* shortest match possible */ #define NRUN (NMATCH+31) /* longest match possible */ #define NMEM 1024 /* window size */ #define NDUMP 128 /* maximum length of dump */ #define NCBLOCK 6000 /* size of compressed blocks */ #define NCMP 11 /* strlen("compressed\n") */ #define NINT 12 /* # of bytes in ascii-encoded integers */ void decompress(uchar *data, int ndata, Rectangle r, int ldepth); int rdblk(int fd, void *blk, int nblk); char *file; void main(int argc, char *argv[]){ int fd, ndata, ldepth, maxy; Rectangle r; char hdr[NCMP+5*NINT], subhdr[2*NINT]; uchar data[NCBLOCK]; if(argc!=2){ fprint(2, "Usage: %s file\n", argv[0]); exits("usage"); } file=argv[1]; fd=open(file, OREAD); if(fd==-1){ fprint(2, "%s: %r\n", file); exits("no open"); } if(!rdblk(fd, hdr, sizeof(hdr))){ fprint(2, "%s: premature eof\n", file); exits("bad eof"); } if(strncmp(hdr, "compressed\n", 11)!=0){ fprint(2, "%s: not compressed\n"); exits("bad input"); } write(1, hdr+NCMP, sizeof(hdr)-NCMP); ldepth=atoi(hdr+NCMP); r.min.x=atoi(hdr+NCMP+NINT); r.min.y=atoi(hdr+NCMP+NINT*2); r.max.x=atoi(hdr+NCMP+NINT*3); r.max.y=atoi(hdr+NCMP+NINT*4); if(r.max.x0) p+=n; if(n<0){ fprint(2, "%s: %r\n", file); exits("bad read"); } return n!=0; } int bytesperline(Rectangle r, int ld){ ulong ws, l, t; ws = 8>>ld; /* pixels per byte */ if(r.min.x >= 0){ l = (r.max.x+ws-1)/ws; l -= r.min.x/ws; }else{ /* make positive before divide */ t = (-r.min.x)+ws-1; t = (t/ws)*ws; l = (t+r.max.x+ws-1)/ws; } return l; } void decompress(uchar *data, int ndata, Rectangle r, int ldepth){ int c, n, offs, nout, bpl; uchar *out, *outp, *eout, *memp, *edata; bpl=bytesperline(r, ldepth); nout=bpl*Dy(r); out=malloc(nout); if(out==0){ fprint(2, "Can't malloc!\n"); exits("no mem"); } outp=out; eout=outp+nout; edata=data+ndata; while(data!=edata){ c=*data++; if(c>=128){ for(n=c-128+1;n!=0;--n){ if(data==edata || outp==eout) goto Done; *outp++=*data++; } } else{ if(data==edata) break; offs=*data++ + ((c&3)<<8)+1; if(offs>outp-out){ fprint(2, "%s: bad offset %d at (%d,%d)\n", file, offs, r.min.x+(outp-out)%bpl, r.min.y+(outp-out)/bpl); exits("offs"); } memp=outp-offs; for(n=(c>>2)+NMATCH;n!=0;--n){ if(outp==eout) goto Done; *outp++=*memp++; } } } Done: write(1, out, nout); if(data!=edata){ fprint(2, "%s: extra compressed data at (%d,%d)\n", file, r.min.x+(outp-out)%bpl, r.min.y+(outp-out)/bpl); exits("phase"); } if(outp!=eout){ fprint(2, "%s: short compressed data at (%d,%d)\n", file, r.min.x+(outp-out)%bpl, r.min.y+(outp-out)/bpl); exits("phase"); } free(out); } //GO.SYSIN DD VADIM /sys/src/fb sum=`{sum < 836422821/enc2bit.c} if(~ d36972e53665 $sum(1)^$sum(2)) echo if not{ echo 836422821/enc2bit.c checksum error extracting new file exit checksum } target=836422821/ikon.c echo -n '836422821/ikon.c (new): ' cat > 836422821/ikon.c >[2]/dev/null <<'//GO.SYSIN DD VADIM /sys/src/fb' #include #include #include #include #include "scsicam.h" #define ISIZE 48 /* ikon size (square) */ #define MAXRANGE (PM/*& ~0x01*/) /* even number for round-off fun */ #define IKONSPACE (ISIZE+4) /* pixels per gallery entry */ Mouse mouse; #define BUTTON(n) ((mouse.buttons >> (n-1)) & 1) #define BUTTON123() ((int)(mouse.buttons & 0x7)) Bitmap display; Font *font; char *name; char *machine; ulong pic[GOODDY][DX]; /* integrated input picture */ ulong edited[ISIZE][ISIZE]; /* selected region from srect */ uchar frame[FRAMESIZE]; /* from the scsicam */ Rectangle Drect; /* our whole display area */ Rectangle frect; /* the big face */ Rectangle mrect; /* the message area */ Rectangle grect; /* the gallery */ Rectangle srect; /* edited rectangle on the big face */ Rectangle machrect; /* machine name */ Rectangle namerect; /* user name */ Rectangle approved[2]; /* approved ikons */ int srectok=0; /* if srect valid */ Bitmap *face=0; Bitmap *camface=0; Bitmap *ikon=0; /* ikon bitmap*/ Bitmap *ikons[2]={0, 0}; /*selected ikons*/ /* gallery information */ int gallok = 0; int xpick = -1; /* x coordinate of current choice */ int xlow=0; /* value of lowest x column */ int xrange=MAXRANGE; /* range covered by each row */ int xcount; /* number of columns in each row */ int xvalue; /* value of choice at xpick */ int ypick; /* y coordinate of current choice */ int ylow=0; /* value of lowest y row */ int yrange=MAXRANGE; /* range covered by each column */ int ycount; /* number of rows in each column */ int yvalue; /* value of choice at ypick */ int mugdepth; int ppbyte; /* pixels per byte */ int maxp; /* max pixel value */ int bpl; /* bytes per line in the bitmap */ char *menu2text[]={ "in", "out", 0 }; enum Menu2{ In, Out, }; char *menu3text[]={ "snap picture", "edit face", "select 2 bit ikon", "select 1 bit ikon", "save ikons", "quit", 0 }; enum Menu3{ Snap, Edit, Select2, Select1, Save, Quit, }; Menu menu2={menu2text}; Menu menu3={menu3text}; void cursorset(Point p); void msg(char *s) { bitblt(&display, mrect.min, &display, mrect, Zero); string(&screen, mrect.min, font, s, S); bflush(); } void box(Rectangle r, int f) { r.max=sub(r.max, Pt(1, 1)); segment(&display, r.min, Pt(r.min.x, r.max.y), ~0, f); segment(&display, Pt(r.min.x, r.max.y), r.max, ~0, f); segment(&display, r.max, Pt(r.max.x, r.min.y), ~0, f); segment(&display, Pt(r.max.x, r.min.y) ,r.min, ~0, f); } void drawborder(Rectangle r) { box(r, DxorS); } ulong floyd[ISIZE+1][ISIZE+1]; ulong contrast_table[PM+1]; void drawface(int lo, int hi, Point facep) { ulong *c, *f; int *ep; int v, h, s, e, temp, i; uchar icon[ISIZE*ISIZE]; if (hi PM) lo=PM; if(hi<0) hi=0; else if(hi > PM) hi=PM; temp = hi - lo; c = contrast_table; /* load the contrast table with current values */ for (v=0; v!=lo; v++) c[v] = 0; for(; v!=hi; v++) c[v] = (v-lo)*PM/temp; for(; v<=PM; v++) c[v] = PM; for(v=0; v!=ISIZE; v++) for(h=0, f=floyd[v]; h!=ISIZE; h++) *f++ = contrast_table[edited[v][h] & PM]; for(v=0; v!=ISIZE; v++){ f = floyd[v]; for(h=0; h PM/2) { i=0; e -= PM; } else i = 1; break; case 2: i = ((1<maxp) i=maxp; e -= (i*PM)/3; i = maxp-i; break; } icon[bpl*v + h] |= i << (8*sizeof(uchar) - mugdepth - mugdepth*s); temp = 3*e/8; f[ISIZE+1] += temp; f[ISIZE+2] += e-2*temp; f[1] += temp; } } } wrbitmap(ikon, 0, ISIZE, (uchar *)icon); bitblt(&display, facep, ikon, Rect(0,0, ISIZE,ISIZE), S); } Rectangle galrect(int x, int y) { Rectangle r; r.min = add(grect.min, Pt(x*IKONSPACE,y*IKONSPACE)); r.max = add(r.min, Pt(ISIZE, ISIZE)); return r; } #define VX(x) (xlow + (xrange/xcount)*x) #define VY(y) (ylow + (yrange/ycount)*y) void show_data(void) { char buf[100]; sprint(buf, "x %d %d %d y %d %d %d", xlow, xrange, xcount, ylow, yrange, ycount); } void showgallery(void) { int x, y; int xv, yv; Rectangle r; bitblt(&display, grect.min, &display, grect, 0); for (x=0; x= yv) drawface(xv, yv, r.min); else bitblt(&display, r.min, &display, r, 0); } } if (xpick >= 0) box(inset(galrect(xpick, ypick), -2), S); gallok = 1; show_data(); } void pickrect(void) { Point p; int x, y, xv, yv; if (!ptinrect(mouse.xy, grect)) return; p = sub(mouse.xy, grect.min); x = (p.x+2)/IKONSPACE; y = (p.y+2)/IKONSPACE; if (VX(x) < VY(y)) /* none displayed there */ return; box(inset(galrect(xpick, ypick), -2), 0); /* clear old box */ xpick = x; ypick = y; box(inset(galrect(xpick, ypick), -2), ~0); show_data(); bflush(); } void zoomset(int oldvx, int oldvy) { int tx, xincr = xrange/xcount; int ty, yincr = yrange/ycount; xpick = xcount / 2; ypick = ycount / 2; xlow = oldvx - xpick*xincr; ylow = oldvy - ypick*yincr; if (xlow < 0) { tx = ((-xlow) / xincr) + 1; xpick -= tx; xlow += tx*xincr; } if (ylow < 0) { ty = ((-ylow) / yincr) + 1; ypick -= ty; ylow += ty*yincr; } } void zoomin(void) { int oldvx = VX(xpick); int oldvy = VY(ypick); box(inset(galrect(xpick, ypick), -2), notS); /* clear old box */ xrange /= 2; if (xrange < xcount) xrange = xcount; yrange /= 2; if (yrange < ycount) yrange = ycount; zoomset(oldvx, oldvy); } void zoomout(void) { int oldvx = VX(xpick); int oldvy = VY(ypick); box(inset(galrect(xpick, ypick), -2), notS); /* clear old box */ xrange *= 2; if (xrange > MAXRANGE) xrange = MAXRANGE; yrange *= 2; if (yrange > MAXRANGE) yrange = MAXRANGE; zoomset(oldvx, oldvy); } int reshape(Rectangle newrect) { Point l1, l0; char buf[100]; Rectangle label1, label0; Drect = inset(newrect, 3); bitblt(&display, Drect.min, &display, Drect, Zero); /* * message area */ mrect.min = Pt(Drect.min.x+20, Drect.max.y - 2 - font->height); mrect.max = Pt(Drect.max.x, Drect.max.y - 2); if (Drect.min.y + 2 + GOODDY + 3 > mrect.min.y || Drect.min.x + 2 + DX + 3 > Drect.max.x) return 0; /* no room for the big picture */ frect.min = Pt(mrect.min.x+20, mrect.min.y-3-GOODDY); frect.max = add(frect.min, Pt(DX, GOODDY)); box(inset(frect, -2), ~0); machrect.max.x = namerect.max.x = frect.max.x; machrect.min.x = namerect.min.x = frect.min.x; machrect.max.y = frect.min.y-5; namerect.max.y = machrect.min.y = machrect.max.y-font->height; namerect.min.y = namerect.max.y-font->height; approved[0].max.y = approved[1].max.y = namerect.min.y - 4; approved[0].min.y = approved[1].min.y = approved[0].max.y - ISIZE; approved[1].min.x = frect.min.x; approved[1].max.x = approved[1].min.x + ISIZE; approved[0].min.x = approved[1].max.x + 20; approved[0].max.x = approved[0].min.x + ISIZE; l1 = sub(approved[1].min, Pt(0, font->height + 5)); l0 = sub(approved[0].min, Pt(0, font->height + 5)); if (l1.y - Drect.min.y > Drect.max.x - frect.max.x) { /* gallery on top */ grect.min = add(Drect.min, Pt(2, 2)); grect.max = Pt(Drect.max.x-2, l1.y-4); } else { /* gallery on the right */ grect.min = Pt(frect.max.x+2, Drect.min.y+2); grect.max = Pt(Drect.max.x-2, mrect.min.y-3); } #define IKONCOUNT(r,axis) ((r.max.axis - r.min.axis)/IKONSPACE) #define MINIKON 3 if ((xcount=IKONCOUNT(grect, x)) < MINIKON || (ycount=IKONCOUNT(grect, y)) < MINIKON) return 0; /* no room for useful gallery */ if (xcount > PM) xcount = PM; if (ycount > PM) ycount = PM; grect.min = Pt(grect.max.x - IKONSPACE*xcount, grect.max.y - IKONSPACE*ycount); xpick = ypick = -1; bitblt(&display, frect.min, face, Rect(0, 0, DX, GOODDY), S); drawborder(inset(approved[1], -2)); drawborder(inset(approved[0], -2)); string(&screen, sub(approved[1].min, Pt(0, font->height + 5)), font, "2 bit", S); string(&screen, sub(approved[0].min, Pt(0, font->height + 5)), font, "1 bit", S); bitblt(&screen, approved[0].min, ikons[0], Rect(0,0,ISIZE,ISIZE), S); bitblt(&screen, approved[1].min, ikons[1], Rect(0,0,ISIZE,ISIZE), S); sprint(buf, "machine: %s", machine); string(&screen, machrect.min, font, buf, S); sprint(buf, " name: %s", name); string(&screen, namerect.min, font, buf, S); if (srectok) { drawborder(raddp(srect, frect.min)); showgallery(); } bflush(); return 1; } void ereshaped(Rectangle newrect) { while (!reshape(newrect)) { msg("Window too small"); mouse = emouse(); } } void xhair(Point p) { if (p.y < frect.max.y && p.y >= frect.min.y) segment(&display, Pt(frect.min.x, p.y), Pt(frect.max.x, p.y), ~0, S^D); if (p.x < frect.max.x && p.x >= frect.min.x) segment(&display, Pt(p.x, frect.min.y), Pt(p.x, frect.max.y), ~0, S^D); } int editface(Rectangle *rp) { Point p, q, r, s; p=mouse.xy; xhair(p); mouse = emouse(); while(!BUTTON123()){ q=mouse.xy; if(!eqpt(p, q)){ xhair(p); p=q; xhair(p); } mouse = emouse(); } xhair(p); if(!ptinrect(q, frect)){ while(BUTTON123()) mouse = emouse(); srectok = 0; return 0; } q=p; box(Rpt(Pt(2*p.x-q.x, p.y), q), S^D); for(; BUTTON123(); mouse = emouse()){ r=mouse.xy; if (r.xfrect.max.x) r.x=frect.max.x; if (r.yfrect.max.y) r.y=frect.max.y; if (2*abs(r.x-p.x)p.x) r.x=p.x+abs(r.y-p.y)/2; else r.x=p.x-abs(r.y-p.y)/2; } else if(r.y>p.y) r.y=p.y+2*abs(r.x-p.x); else r.y=p.y-2*abs(r.x-p.x); if(!eqpt(r, q)){ box(Rpt(Pt(2*p.x-q.x, p.y), q), S^D); q=r; box(Rpt(Pt(2*p.x-q.x, p.y), q), S^D); } } box(Rpt(Pt(2*p.x-q.x, p.y), q), S^D); rp->min=Pt(2*p.x-q.x, p.y); rp->max=q; *rp = rsubp(rcanon(*rp), frect.min); srectok = 1; return 1; } int sample(int x0, int y0, int x1, int y1) { int v, u; if(x1==x0) x1++; if(y1==y0) y1++; if(x0==0){ if(y0 == 0) v = pic[y1-1][x1-1]; else v = pic[y1-1][x1-1] - pic[y0-1][x1-1]; } else if (y0 == 0) v = pic[y1-1][x1-1] - pic[y1-1][x0-1]; else v = pic[y1-1][x1-1] - pic[y0-1][x1-1] - pic[y1-1][x0-1] + pic[y0-1][x0-1]; u = v/(y1-y0)/(x1-x0); return u; } void getedited(Rectangle r) { int x, y, x0, y0, x1, y1; x0 = r.min.x; y0 = r.min.y; x1 = r.max.x; y1 = r.max.y; if(x0<0) x0=0; else if(DX<=x0) x0=DX-1; if(y0<0) y0=0; else if(DY<=y0) y0=DY-1; if(x1<=x0) x1=x0+1; else if(DX> shift) & PM; shift -= BPP; if (shift < 0) { cp++; shift = 8-BPP; } } /* * set each row to the sum of the previous rows. */ for(x=1; x3 */ uchar *cp = picbitmap; ulong *w; int screen_bpp = (1<3) i=3; e -= (i*(1< 836422821/junk.c >[2]/dev/null <<'//GO.SYSIN DD VADIM /sys/src/fb' #include #include #include #include #include #include /* * exits defined here because of ludicrous library lossage */ void exits(char *s){ void exit(int); exit(s && *s); } void main(void){ PICFILE *out; /* TIFFOpen("/usr/seanq/test.tif", "r"); */ out=picopen_w("OUT", "runcode", 0, 0, 100, 100, "m", 0, 0); fprint(2, "fd returned by picopen_w is %d\n", out->fd); fprint(out->fd, "write on fd %d\n", out->fd); fprint(1, "write on fd 1\n"); exits(0); } //GO.SYSIN DD VADIM /sys/src/fb sum=`{sum < 836422821/junk.c} if(~ 77c50d17516 $sum(1)^$sum(2)) echo if not{ echo 836422821/junk.c checksum error extracting new file exit checksum } target=836422821/mugs.c echo -n '836422821/mugs.c (new): ' cat > 836422821/mugs.c >[2]/dev/null <<'//GO.SYSIN DD VADIM /sys/src/fb' #include #include #include #include #define rectf(b,r,f) bitblt(b,r.min,b,r,f) /* stub - remove rectf */ #define FSIZE 256 #define RES 255 /* resolution of FSIZE*FSIZE picture */ #define ISIZE 48 /* ikon size (square) */ #define MAXBPP 2 /* max bits per pixel to bitmapped display */ #define MAXPV ((1<> (n-1)) & 1) #define BUTTON123() ((int)(mouse.buttons & 0x7)) Font *font; char *name; ulong pic[FSIZE][FSIZE]; /* input picture reduced to FSIZE*FSIZE*RES and integrated */ ulong edited[ISIZE][ISIZE]; /* selected region from srect */ Rectangle Drect; /* our whole display area */ Rectangle frect; /* the big face */ Rectangle mrect; /* the message area */ Rectangle grect; /* the gallery */ Rectangle srect; /* edited rectangle on the big face */ int srectok=0; /* if srect valid */ int rescale=0; /* if 5/4 ratio pixels */ Bitmap *face=0; Bitmap *ikon=0; /* ikon bitmap*/ /* gallery information */ int xpick; /* x coordinate of current choice */ int xlow=0; /* value of lowest x column */ int xrange=MAXRANGE; /* range covered by each row */ int xcount; /* number of columns in each row */ int xvalue; /* value of choice at xpick */ int ypick; /* y coordinate of current choice */ int ylow=0; /* value of lowest y row */ int yrange=MAXRANGE; /* range covered by each column */ int ycount; /* number of rows in each column */ int yvalue; /* value of choice at ypick */ int mugdepth; int ppbyte; /* pixels per byte */ int maxp; /* max pixel value */ int bpl; /* bytes per line in the bitmap */ char *menu2text[]={ "in", "out", "reset", 0 }; enum Menu2{ In, Out, Reset, }; char *menu3text[]={ "window", "depth", "write", "abort", "finish", 0 }; enum Menu3{ Window, Depth, Write, Abort, Finish }; Menu menu2={menu2text}; Menu menu3={menu3text}; void cursorset(Point p); void show_data(void); void msg(char *s) { rectf(&screen, mrect, Zero); string(&screen, mrect.min, font, s, S); } void box(Rectangle r, int f) { r.max=sub(r.max, Pt(1, 1)); segment(&screen, r.min, Pt(r.min.x, r.max.y), ~0, f); segment(&screen, Pt(r.min.x, r.max.y), r.max, ~0, f); segment(&screen, r.max, Pt(r.max.x, r.min.y), ~0, f); segment(&screen, Pt(r.max.x, r.min.y) ,r.min, ~0, f); } void drawborder(Rectangle r) { box(r, DxorS); } ulong floyd[ISIZE+1][ISIZE+1]; ulong contrast_table[RES+1]; void drawface(int lo, int hi, Point facep) { ulong *c, *f; int v, h, s, e, temp, i; uchar icon[ISIZE*ISIZE]; if (hi RES/2) { i=0; e -= RES; } else i = 1; break; case 2: i = ((1<maxp) i=maxp; e -= (i*RES)/3; i = maxp-i; break; } icon[bpl*v + h] |= i << (8*sizeof(uchar) - mugdepth - mugdepth*s); temp = 3*e/8; f[ISIZE+1] += temp; f[ISIZE+2] += e-2*temp; f[1] += temp; } } } wrbitmap(ikon, 0, 48, (uchar *)icon); bitblt(&screen, facep, ikon, Rect(0,0, 48,48), S); } Rectangle galrect(int x, int y) { Rectangle r; r.min = add(grect.min, Pt(x*IKONSPACE,y*IKONSPACE)); r.max = add(r.min, Pt(ISIZE, ISIZE)); return r; } #define VX(x) (xlow + (xrange/xcount)*x) #define VY(y) (ylow + (yrange/ycount)*y) void showgallery(void) { int x, y; int xv, yv; Rectangle r; box(inset(galrect(xpick, ypick), -2), notS); /* clear old box */ for (y=0; y= yv) drawface(xv, yv, r.min); else rectf(&screen, r, Zero); } box(inset(galrect(xpick, ypick), -2), S); } void pickrect(void) { Point p; int x, y; if (!ptinrect(mouse.xy, grect)) return; p = sub(mouse.xy, grect.min); x = (p.x+2)/IKONSPACE; y = (p.y+2)/IKONSPACE; if (VX(x) < VY(y)) /* none displayed there */ return; box(inset(galrect(xpick, ypick), -2), notS); /* clear old box */ xpick = x; ypick = y; box(inset(galrect(xpick, ypick), -2), S); show_data(); } void zoomset(int oldvx, int oldvy) { int tx, xincr = xrange/xcount; int ty, yincr = yrange/ycount; xpick = xcount / 2; ypick = ycount / 2; xlow = oldvx - xpick*xincr; ylow = oldvy - ypick*yincr; if (xlow < 0) { tx = ((-xlow) / xincr) + 1; xpick -= tx; xlow += tx*xincr; } if (ylow < 0) { ty = ((-ylow) / yincr) + 1; ypick -= ty; ylow += ty*yincr; } show_data(); } void zoomin(void) { int oldvx = VX(xpick); int oldvy = VY(ypick); box(inset(galrect(xpick, ypick), -2), notS); /* clear old box */ xrange /= 2; if (xrange < xcount) xrange = xcount; yrange /= 2; if (yrange < ycount) yrange = ycount; zoomset(oldvx, oldvy); } void zoomout(void) { int oldvx = VX(xpick); int oldvy = VY(ypick); box(inset(galrect(xpick, ypick), -2), notS); /* clear old box */ xrange *= 2; if (xrange > MAXRANGE) xrange = MAXRANGE; yrange *= 2; if (yrange > MAXRANGE) yrange = MAXRANGE; zoomset(oldvx, oldvy); } int reshape(Rectangle newrect) { screen.r=newrect; Drect = inset(newrect, 3); rectf(&screen,Drect,Zero); mrect.min = Pt(Drect.min.x+2, Drect.max.y - 2 - font->height); mrect.max = Pt(Drect.max.x, Drect.max.y - 2); if (Drect.min.y + 2 + 256 + 3 > mrect.min.y || Drect.min.x + 2 + 256 + 3 > Drect.max.x) return 0; /* no room for the big picture */ frect.min = Pt(mrect.min.x+2, mrect.min.y-3-256); frect.max = add(frect.min, Pt(256, 256)); if (frect.min.y - Drect.min.y > Drect.max.x - frect.max.x) { /* gallery on top */ grect.min = add(Drect.min, Pt(2, 2)); grect.max = Pt(Drect.max.x-2, frect.min.y-3); } else { /* gallery on the right */ grect.min = Pt(frect.max.x+2, Drect.min.y+2); grect.max = Pt(Drect.max.x-2, mrect.min.y-3); } #define IKONCOUNT(r,axis) ((r.max.axis - r.min.axis)/IKONSPACE) #define MINIKON 3 if ((xcount=IKONCOUNT(grect, x)) < MINIKON || (ycount=IKONCOUNT(grect, y)) < MINIKON) return 0; /* no room for useful gallery */ grect.min = Pt(grect.max.x - IKONSPACE*xcount, grect.max.y - IKONSPACE*ycount); show_data(); bitblt(&screen, frect.min, face, Rect(0,0,256,256), S); if (srectok) drawborder(raddp(srect, frect.min)); xpick = xcount/2; /* stub - this is lazy */ ypick = 0; showgallery(); return 1; /* reshape ok */ } void show_data(void) { char buf[100]; sprint(buf, "%s depth=%d low=%d/%d range=%d/%d picked: %d-%d", name, mugdepth, xlow, ylow, xrange, yrange, VX(xpick), VY(ypick)); msg(buf); } void ereshaped(Rectangle newrect) { while (!reshape(newrect)) { msg("Window too small"); bflush(); mouse = emouse(); } } void xhair(Point p) { if (frect.min.y<=p.y && p.yfrect.max.x) r.x=frect.max.x; if (r.yfrect.max.y) r.y=frect.max.y; if (2*abs(r.x-p.x)p.x) r.x=p.x+abs(r.y-p.y)/2; else r.x=p.x-abs(r.y-p.y)/2; } else if(r.y>p.y) r.y=p.y+2*abs(r.x-p.x); else r.y=p.y-2*abs(r.x-p.x); if(!eqpt(r, q)){ box(Rpt(Pt(2*p.x-q.x, p.y), q), S^D); q=r; box(Rpt(Pt(2*p.x-q.x, p.y), q), S^D); } bflush(); } box(Rpt(Pt(2*p.x-q.x, p.y), q), S^D); rp->min=Pt(2*p.x-q.x, p.y); rp->max=q; *rp = rsubp(rcanon(*rp), frect.min); return 1; } int sample(int x0, int y0, int x1, int y1) { int v, u; if(rescale){ x0/=1.25; x0+=25; x1/=1.25; x1+=25; } if(x1==x0) x1++; if(y1==y0) y1++; if(x0==0){ if(y0 == 0) v = pic[y1-1][x1-1]; else v = pic[y1-1][x1-1] - pic[y0-1][x1-1]; } else if (y0 == 0) v = pic[y1-1][x1-1] - pic[y1-1][x0-1]; else v = pic[y1-1][x1-1] - pic[y0-1][x1-1] - pic[y1-1][x0-1] + pic[y0-1][x0-1]; u = v/(y1-y0)/(x1-x0); if(u>255) fprint(2, "%d %d, %d %d: %d %d\n", x0, y0, x1, y1, u, v); return u; } void getedited(Rectangle r) { int x, y, x0, y0, x1, y1; x0 = r.min.x; y0 = r.min.y; x1 = r.max.x; y1 = r.max.y; if(x0<0) x0=0; else if(FSIZE<=x0) x0=FSIZE-1; if(y0<0) y0=0; else if(FSIZE<=y0) y0=FSIZE-1; if(x1<=x0) x1=x0+1; else if(FSIZE b) ? a : b) shrnk=imax(1, imax((pheight+FSIZE-1)/FSIZE, (pwidth+FSIZE-1)/FSIZE)); for(y=0; y!=FSIZE; y++) for(x=0; x!=FSIZE; x++) pic[y][x] = 0; for(y=0; y!=pheight; y++){ picread(p, (char *)v); for(x=0,vp=v; x!=pwidth; x++,vp+=p->nchan) pic[y/shrnk][x/shrnk] += p->nchan<3?*vp:(vp[0]+vp[1]+vp[2])/3; } /* adjust values for shrinkage */ for(y=0; y!=FSIZE; y++) for(x=0; xMAXPV) i=MAXPV; e -= (i*RES)/MAXPV; picbitmap[y][x/MAXPPBYTE] |= (MAXPV-i) << (MAXPPBYTE - (x % MAXPPBYTE) - 1)*MAXBPP; #ifndef broken t = (e+e+e)/8; floyd[(y+1)&1][x] += t; floyd[(y+1)&1][x+1] += e-t-t; floyd[y&1][x+1] += t; #endif } } wrbitmap(face, 0, 256, (uchar *)picbitmap); return; } void do_write(void) { int x, y; switch (mugdepth) { case 1: { ushort icon[ISIZE][ISIZE/(8*sizeof(ushort))]; bitblt(ikon, Pt(0,0), &screen, galrect(xpick, ypick), S); rdbitmap(ikon, 0, ISIZE, (uchar *)icon); for (y=0; y 836422821/paint.c >[2]/dev/null <<'//GO.SYSIN DD VADIM /sys/src/fb' #include #include #include #include int wid, hgt, ldepth; char *pictype="plan9"; char *picname="paint.out"; uchar color=255; int nperiod; int npalx, npaly, pskip; uchar **image; Bitmap *cbm; char *but3[]={ "save", "exit", 0 }; Menu menu3={but3}; Rectangle palette; Point palsq; Rectangle big; Rectangle small; Point picsq; Rectangle palrect(int c){ Rectangle r; r.min.x=palette.min.x+palsq.x*(c/pskip%npalx); r.min.y=palette.min.y+palsq.y*(c/pskip/npalx); r.max=add(r.min, palsq); return r; } void showpal(int c){ Rectangle r; r=palrect(c); point(cbm, Pt(0,0), c, S); texture(&screen, inset(r, 1), cbm, S); } void markpal(int c){ Rectangle r; r=palrect(c); border(&screen, inset(r, 1), 1, F); border(&screen, inset(r, 2), 1, Zero); } void showpic(int x, int y){ Rectangle r; int px, py; r.min.x=big.min.x+picsq.x*x; r.min.y=big.min.y+picsq.y*y; r.max=add(r.min, picsq); point(cbm, Pt(0,0), 255-image[y][x], S); texture(&screen, r, cbm, S); border(&screen, r, 1, F); for(py=0;py!=nperiod;py++) for(px=0;px!=nperiod;px++) point(&screen, add(small.min, Pt(px*wid+x, py*hgt+y)), 255-image[y][x], S); } void paint(Point p){ if(!ptinrect(p, big)) return; p=sub(p, big.min); p.x/=picsq.x; p.y/=picsq.y; if(image[p.y][p.x]!=255-color){ image[p.y][p.x]=255-color; showpic(p.x, p.y); } } void setcolor(Point p){ uchar new[1]; if(ptinrect(p, screen.clipr)){ bitblt(cbm, Pt(0,0), &screen, raddp(Rect(0,0,1,1), p), S); rdbitmap(cbm, 0, 1, new); if(color!=new[0]){ showpal(color); color=new[0]; markpal(color); } } } void ereshaped(Rectangle r){ int x, y, i; screen.r=r; bitblt(&screen, screen.r.min, &screen, screen.r, Zero); r=inset(r, 3); palsq.x=(r.max.x-r.min.x)/npalx; if(palsq.x>20) palsq.x=20; palsq.y=palsq.x; palette.min.x=(r.min.x+r.max.x-npalx*palsq.x)/2; palette.min.y=r.max.y-npaly*palsq.y; palette.max.x=palette.min.x+npalx*palsq.x; palette.max.y=r.max.y; border(&screen, inset(palette, -2), 1, F); for(i=0;i<=255;i+=pskip) showpal(i); markpal(color); small.max.y=palette.min.y-4; small.min.y=small.max.y-nperiod*hgt; small.min.x=(r.min.x+r.max.x-nperiod*wid)/2; small.max.x=small.min.x+nperiod*wid; r.max.y=small.min.y-4; r=inset(r, 1); picsq.x=(r.max.x-r.min.x)/wid; picsq.y=(r.max.y-r.min.y)/hgt; if(picsq.x>picsq.y) picsq.x=picsq.y; else picsq.y=picsq.x; big.min.x=(r.min.x+r.max.x-wid*picsq.x)/2; big.min.y=(r.min.y+r.max.y-hgt*picsq.y)/2; big.max.x=big.min.x+wid*picsq.x; big.max.y=big.min.y+hgt*picsq.y; border(&screen, inset(big, -1), 1, F); for(y=0;y!=hgt;y++) for(x=0;x!=wid;x++) showpic(x, y); } void save(void){ PICFILE *out; int y; char buf[10]; out=picopen_w(picname, pictype, 0, 0, wid, hgt, "m", 0, 0); if(out==0){ fprint(2, "Sorry, can't save!\n"); return; } sprint(buf, "%d", ldepth); picputprop(out, "LDEPTH", buf); for(y=0;y!=hgt;y++) picwrite(out, image[y]); picclose(out); } void main(int argc, char *argv[]){ int y; Mouse m; PICFILE *in; char *s; char *savebut; argc=getflags(argc, argv, "pl:1[ldepth]t:1[type]f:1[file]"); switch(argc){ default: usage("[width height]"); case 3: wid=atoi(argv[1]); hgt=atoi(argv[2]); break; case 1: wid=-1; hgt=-1; break; } in=0; ldepth=3; if(flag['f']){ picname=flag['f'][0]; if(wid==-1){ in=picopen_r(picname); if(in==0){ fprint(2, "%s: %r\n", picname); exits("no picopen"); } if(PIC_NCHAN(in)!=1){ fprint(2, "Sorry, can only handle one channel!\n"); exits("range"); } wid=PIC_WIDTH(in); hgt=PIC_HEIGHT(in); s=picgetprop(in, "LDEPTH"); if(s) ldepth=atoi(s); } } nperiod=flag['p']?3:1; if(flag['t']) pictype=flag['t'][0]; if(flag['l']) ldepth=atoi(flag['l'][0]); if(wid<=0 || hgt<=0){ fprint(2, "%s: size must be positive\n", argv[0]); exits("range"); } switch(ldepth){ default: fprint(2, "%s: bad ldepth=%d\n", ldepth); exits("range"); case 0: npalx=2; npaly=1; break; case 1: npalx=4; npaly=1; break; case 2: npalx=16;npaly=1; break; case 3: npalx=32;npaly=8; break; } pskip=255/((1<<(1< 836422821/scale.c >[2]/dev/null <<'//GO.SYSIN DD VADIM /sys/src/fb' /*% cc -go # % libfb.a * scale -- resample an image (just does point resampling) */ #include #include #include main(int argc, char *argv[]){ PICFILE *in, *out; char *iline, *oline, *ip, *op; int iy, y, x, i; int iwid, ihgt, nchan, owid, ohgt; if((argc=getflags(argc, argv, "w:1[width]h:1[height]"))!=1 && argc!=2) usage("[picture]"); if(!flag['w'] && !flag['h']){ fprint(2, "%s: must set at least one of -w, -h\n", argv[0]); exits("usage"); } in=picopen_r(argc==2?argv[1]:"IN"); if(in==0){ perror(argc==2?argv[1]:"IN"); exits("open input"); } iwid=PIC_WIDTH(in); ihgt=PIC_HEIGHT(in); nchan=PIC_NCHAN(in); if(flag['w']){ owid=atoi(flag['w'][0]); if(flag['h']) ohgt=atoi(flag['h'][0]); else ohgt=owid*ihgt/iwid; } else{ ohgt=atoi(flag['h'][0]); owid=ohgt*iwid/ihgt; } iline=malloc(iwid*nchan); oline=malloc(owid*nchan); if(iline==0 || oline==0){ fprint(2, "%s: no space\n", argv[0]); exits("no space"); } out=picopen_w("OUT", in->type, 0, 0, owid, ohgt, in->chan, argv, in->cmap); if(out==0){ perror("OUT"); exits("create output"); } iy=-1; for(y=0;y!=ohgt;y++){ while(y*(ihgt-1)/(ohgt-1)>iy){ picread(in, iline); iy++; } op=oline; for(x=0;x!=owid;x++){ ip=&iline[x*(iwid-1)/(owid-1)*nchan]; for(i=0;i!=nchan;i++) *op++=*ip++; } picwrite(out, oline); } exits(0); } //GO.SYSIN DD VADIM /sys/src/fb sum=`{sum < 836422821/scale.c} if(~ 8f16dcf91377 $sum(1)^$sum(2)) echo if not{ echo 836422821/scale.c checksum error extracting new file exit checksum } target=836422821/twb.r echo -n '836422821/twb.r (new): ' cat > 836422821/twb.r >[2]/dev/null <<'//GO.SYSIN DD VADIM /sys/src/fb' #!/bin/rc fn sigexit sigint sigquit sighup{ rm -f /tmp/twb.$pid } troffflags=-mtwb dpicflags=() files=() for(i) switch($i){ case -[TFds]* -I; dpicflags=($dpicflags $i) case -w*; dpicflags=($dpicflags `{echo $i|sed 's/,/ /g'}) case -[mo]*; troffflags=($troffflags $i) case *; files=($files $i) } cat $files>/tmp/twb.$pid grap='' pic='' eqn='' tbl='' for(i in `{grep '^\.(G1|PS|EQ|TS)' /tmp/twb.$pid | sed 's/(...).*/\1/' | sort -u}) switch($i){ case .G1; grap='grap |' pic='pic -D |' case .PS; pic='pic -D |' case .EQ; eqn='eqn -p5 -s30 -Ttwb |' case .TS; tbl='tbl |' } eval $grap $pic $tbl $eqn troff -Ttwb $troffflags