*** disk$vis:[xv.orig]bggen.c --- bggen.c ************** *** 29,34 #define DEFSIZE 1024 #define MAXCOLS 128 struct color { int r,g,b; int y; } cols[MAXCOLS], *cur, *nex; int bmask[8] = { 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; --- 29,37 ----- #define DEFSIZE 1024 #define MAXCOLS 128 + #ifdef VMS + struct color { int r,g,b; int y; } colors[MAXCOLS], *cur, *nex; + #else struct color { int r,g,b; int y; } cols[MAXCOLS], *cur, *nex; #endif ************** *** 30,35 #define MAXCOLS 128 struct color { int r,g,b; int y; } cols[MAXCOLS], *cur, *nex; int bmask[8] = { 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; --- 33,39 ----- struct color { int r,g,b; int y; } colors[MAXCOLS], *cur, *nex; #else struct color { int r,g,b; int y; } cols[MAXCOLS], *cur, *nex; + #endif int bmask[8] = { 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff }; ************** *** 44,49 int bits = 8; int r, g, b; cnt = 0; numcols = 0; for (i=1; i2 && strcmp(basename+strlen(basename)-2,".Z")==0) --- 713,719 ----- tmp = rindex(fullname,']'); #else tmp = rindex(fullname,'/'); + #endif if (!tmp) tmp = fullname; else tmp++; strcpy(basename,tmp); if (strlen(basename)>2 && strcmp(basename+strlen(basename)-2,".Z")==0) ************** *** 722,727 freename = 0; if (fullname[0] != '/' && strcmp(fullname,STDINSTR)!=0) { char *tmp; tmp = (char *) malloc(strlen(fullname) + strlen(initpath) + 2); if (!tmp) FatalError("malloc 'filename' failed"); sprintf(tmp,"%s/%s", initpath, fullname); --- 724,732 ----- freename = 0; if (fullname[0] != '/' && strcmp(fullname,STDINSTR)!=0) { char *tmp; + #ifdef VMS + tmp = (char *) malloc(strlen(fullname) + 2); + #else tmp = (char *) malloc(strlen(fullname) + strlen(initpath) + 2); #endif if (!tmp) FatalError("malloc 'filename' failed"); ************** *** 723,728 if (fullname[0] != '/' && strcmp(fullname,STDINSTR)!=0) { char *tmp; tmp = (char *) malloc(strlen(fullname) + strlen(initpath) + 2); if (!tmp) FatalError("malloc 'filename' failed"); sprintf(tmp,"%s/%s", initpath, fullname); fullname = tmp; --- 728,734 ----- tmp = (char *) malloc(strlen(fullname) + 2); #else tmp = (char *) malloc(strlen(fullname) + strlen(initpath) + 2); + #endif if (!tmp) FatalError("malloc 'filename' failed"); #ifdef VMS sprintf(tmp,"%s", fullname); ************** *** 724,729 char *tmp; tmp = (char *) malloc(strlen(fullname) + strlen(initpath) + 2); if (!tmp) FatalError("malloc 'filename' failed"); sprintf(tmp,"%s/%s", initpath, fullname); fullname = tmp; freename = 1; --- 730,738 ----- tmp = (char *) malloc(strlen(fullname) + strlen(initpath) + 2); #endif if (!tmp) FatalError("malloc 'filename' failed"); + #ifdef VMS + sprintf(tmp,"%s", fullname); + #else sprintf(tmp,"%s/%s", initpath, fullname); #endif fullname = tmp; ************** *** 725,730 tmp = (char *) malloc(strlen(fullname) + strlen(initpath) + 2); if (!tmp) FatalError("malloc 'filename' failed"); sprintf(tmp,"%s/%s", initpath, fullname); fullname = tmp; freename = 1; } --- 734,740 ----- sprintf(tmp,"%s", fullname); #else sprintf(tmp,"%s/%s", initpath, fullname); + #endif fullname = tmp; freename = 1; } ************** *** 752,757 if (strcmp(filename,STDINSTR)==0) { FILE *fp; strcpy(filename,"/tmp/xvXXXXXX"); mktemp(filename); --- 762,770 ----- if (strcmp(filename,STDINSTR)==0) { FILE *fp; + #ifdef VMS + strcpy(filename,"Sys$Disk:[]xvXXXXXX"); + #else strcpy(filename,"/tmp/xvXXXXXX"); #endif mktemp(filename); ************** *** 753,758 FILE *fp; strcpy(filename,"/tmp/xvXXXXXX"); mktemp(filename); fp = fopen(filename,"w"); --- 766,772 ----- strcpy(filename,"Sys$Disk:[]xvXXXXXX"); #else strcpy(filename,"/tmp/xvXXXXXX"); + #endif mktemp(filename); fp = fopen(filename,"w"); ************** *** 756,761 mktemp(filename); fp = fopen(filename,"w"); if (!fp) FatalError("can't write /tmp/xv****** file"); while ( (i=getchar()) != EOF) putc(i,fp); --- 770,778 ----- mktemp(filename); fp = fopen(filename,"w"); + #ifdef VMS + if (!fp) FatalError("can't write Sys$Disk:[]xv****** file"); + #else if (!fp) FatalError("can't write /tmp/xv****** file"); #endif ************** *** 757,762 fp = fopen(filename,"w"); if (!fp) FatalError("can't write /tmp/xv****** file"); while ( (i=getchar()) != EOF) putc(i,fp); fclose(fp); --- 774,780 ----- if (!fp) FatalError("can't write Sys$Disk:[]xv****** file"); #else if (!fp) FatalError("can't write /tmp/xv****** file"); + #endif while ( (i=getchar()) != EOF) putc(i,fp); fclose(fp); ************** *** 768,773 fp=fopen(filename,"r"); if (!fp) { SetISTR(ISTR_INFO,"Can't open '%s' - %s",filename,sys_errlist[errno]); Warning(); goto FAILED; --- 786,794 ----- fp=fopen(filename,"r"); if (!fp) { + #ifdef VMS + SetISTR(ISTR_INFO,"Can't open '%s'",filename); + #else SetISTR(ISTR_INFO,"Can't open '%s' - %s",filename,sys_errlist[errno]); #endif Warning(); ************** *** 769,774 fp=fopen(filename,"r"); if (!fp) { SetISTR(ISTR_INFO,"Can't open '%s' - %s",filename,sys_errlist[errno]); Warning(); goto FAILED; } --- 790,796 ----- SetISTR(ISTR_INFO,"Can't open '%s'",filename); #else SetISTR(ISTR_INFO,"Can't open '%s' - %s",filename,sys_errlist[errno]); + #endif Warning(); goto FAILED; } ************** *** 777,783 fclose(fp); filetype = UNKNOWN; ! if (strncmp(magicno,"GIF87",5)==0) filetype = GIF; else if (strncmp(magicno,"VIEW",4)==0 || strncmp(magicno,"WEIV",4)==0) filetype = PM; --- 799,805 ----- fclose(fp); filetype = UNKNOWN; ! if (strncmp(magicno,"GIF",3)==0) filetype = GIF; else if (magicno[0] == -1 && magicno[1] == -40 && ************** *** 779,784 filetype = UNKNOWN; if (strncmp(magicno,"GIF87",5)==0) filetype = GIF; else if (strncmp(magicno,"VIEW",4)==0 || strncmp(magicno,"WEIV",4)==0) filetype = PM; --- 801,810 ----- filetype = UNKNOWN; if (strncmp(magicno,"GIF",3)==0) filetype = GIF; + else if (magicno[0] == -1 && + magicno[1] == -40 && + magicno[2] == -1) filetype = JFIF; + else if (strncmp(magicno,"VIEW",4)==0 || strncmp(magicno,"WEIV",4)==0) filetype = PM; ************** *** 796,805 SetISTR(ISTR_INFO,"Loading '%s'...",basename); switch (filetype) { ! case GIF: i = LoadGIF(filename,ncols); break; ! case PM: i = LoadPM (filename,ncols); break; ! case PBM: i = LoadPBM(filename,ncols); break; ! case XBM: i = LoadXBM(filename,ncols); break; } WaitCursor(); --- 822,834 ----- SetISTR(ISTR_INFO,"Loading '%s'...",basename); switch (filetype) { ! case GIF: i = LoadGIF (filename,ncols); break; ! case PM: i = LoadPM (filename,ncols); break; ! case PBM: i = LoadPBM (filename,ncols); break; ! case XBM: i = LoadXBM (filename,ncols); break; ! /* not avaiable yet ! case JFIF: i = LoadJFIF(filename,ncols); break; ! */ } WaitCursor(); ************** *** 960,969 XFreeColormap(theDisp,LocalCmap); LocalCmap = 0; } - else if (!brokeFreeCols) { - for (i=0; iheight) { --- 1808,1814 ----- * twm where resize was giving 23 extra lines... * should do no harm if this bug is not present. */ + #ifdef TWMKLUDGE XSync(theDisp,False); XGetWindowAttributes(theDisp, mainW, &pxwa); if (pxwa.height != xwa->height) { ************** *** 1803,1808 XResizeWindow(theDisp, mainW, xwa->width, xwa->height - (pxwa.height - xwa->height)); } } --- 1821,1827 ----- XResizeWindow(theDisp, mainW, xwa->width, xwa->height - (pxwa.height - xwa->height)); } + #endif /* TWMKLUDGE */ } ************** *** 2039,2044 /* returns true if there's a config event in which mainW changes size in the event queue */ foo = 0; XCheckIfEvent(theDisp, &ev, IsConfig, &foo); return foo; --- 2058,2064 ----- /* returns true if there's a config event in which mainW changes size in the event queue */ + XSync(theDisp, False); foo = 0; XCheckIfEvent(theDisp, &ev, IsConfig, &foo); return foo; ************** *** 2224,2233 /* returns '1' if successful. result in def_str */ if (def_str = XGetDefault(theDisp, PROGNAME, name)) { ! def_int = (strcmp(def_str, "on")==0) || ! (strcmp(def_str, "1")==0) || ! (strcmp(def_str, "true")==0) || ! (strcmp(def_str, "yes")==0); return 1; } --- 2244,2250 ----- /* returns '1' if successful. result in def_str */ if (def_str = XGetDefault(theDisp, PROGNAME, name)) { ! def_int = rd_boolean(def_str); return 1; } ************** *** 2234,2239 else return 0; } --- 2251,2335 ----- else return 0; } + void XvFreeColors(display, colormap, pixels, npixels, planes, nfcols) + Display * display; + Colormap colormap; + unsigned long * pixels; + int npixels; + unsigned long planes; + int nfcols; + { + int i; + + XSetErrorHandler(XvErrorHandler); /* Handle X_FreeColors error messages */ + for (i=0; i MAXKEYWORDLEN) + { /* Nope, must no be a valid value */ + return 0; + } + else + { /* get a local copy of value */ + (void) strncpy(tmp, value, MAXKEYWORDLEN + 1); + } + + /* convert the local copy to lower case */ + ptr = tmp; + while (*ptr != '\0') + { + *ptr = isupper(*ptr) ? tolower(*ptr) : *ptr; + ptr++; + } + + /* search the array of keywords for a match */ + i = 0; + match = 0; + while (keywords[i] != (char *) 0) + { + if (strcmp(tmp, keywords[i]) == 0) + { + match = 1; + } + i++; + } + + return(match); + } + *** disk$vis:[xv.orig]xv.h --- xv.h ************** *** 30,35 #include #include #include extern int errno; /* this SHOULD be in errno.h */ extern char *sys_errlist[]; /* this SHOULD be in errno.h */ --- 30,38 ----- #include #include #include + #ifdef VMS + #include + #else extern int errno; /* this SHOULD be in errno.h */ extern char *sys_errlist[]; /* this SHOULD be in errno.h */ #endif ************** *** 32,37 #include extern int errno; /* this SHOULD be in errno.h */ extern char *sys_errlist[]; /* this SHOULD be in errno.h */ #ifndef __convexc__ /* Convex doesn't have */ #include /* for 'memset()' prototype */ --- 35,41 ----- #else extern int errno; /* this SHOULD be in errno.h */ extern char *sys_errlist[]; /* this SHOULD be in errno.h */ + #endif /* Convex and VMS doesn't have */ #if !(defined(__convexc__) || defined(VMS)) ************** *** 33,39 extern int errno; /* this SHOULD be in errno.h */ extern char *sys_errlist[]; /* this SHOULD be in errno.h */ ! #ifndef __convexc__ /* Convex doesn't have */ #include /* for 'memset()' prototype */ #endif --- 37,44 ----- extern char *sys_errlist[]; /* this SHOULD be in errno.h */ #endif ! /* Convex and VMS doesn't have */ ! #if !(defined(__convexc__) || defined(VMS)) #include /* for 'memset()' prototype */ #endif ************** *** 38,45 #endif /* neither IBM AOS 4.3, Convex, nor BSD 4.3 on VAX have */ ! #if !defined(ibm032) && !defined(__convexc__) && \ ! !(defined(vax) && !defined(ultrix)) #if defined(hp300) || defined(hp800) #include /* it's in 'sys' on HPs*/ #else --- 43,49 ----- #endif /* neither IBM AOS 4.3, Convex, nor BSD 4.3 on VAX have */ ! #if !defined(ibm032) && !defined(__convexc__) && !(defined(vax) && !defined(ultrix)) #if defined(hp300) || defined(hp800) #include /* it's in 'sys' on HPs*/ #else ************** *** 52,57 #define memcpy(d,s,l) bcopy(s,d,l) #endif #include #include --- 56,67 ----- #define memcpy(d,s,l) bcopy(s,d,l) #endif + #ifdef VMS + #define bcopy(src,dst,len) memcpy(dst,src,len) + #define unlink remove + #define index(s,c) strchr(s,c) + #define rindex(s,c) strrchr(s,c) + #endif #include #include ************** *** 68,73 #ifndef sgi /* silicon graphics doesn't have timeb.h */ #include #endif #include #if defined(sco) && !defined(NOTIMER) #include --- 78,84 ----- #ifndef sgi /* silicon graphics doesn't have timeb.h */ #include #endif + #undef SIGCHLD #include #if defined(sco) && !defined(NOTIMER) #include ************** *** 78,83 #endif #ifdef NEEDSDIR #ifdef sco #include #define lstat stat --- 89,95 ----- #endif #ifdef NEEDSDIR + #ifndef HPUX #ifdef sco #include #define lstat stat ************** *** 86,91 #include #endif /* ATT */ #endif /* sco */ #include #include #ifdef DIRENT --- 98,105 ----- #include #endif /* ATT */ #endif /* sco */ + #endif /* not HPUX */ + #ifndef VMS #include #endif /* not VMS */ #include ************** *** 87,92 #endif /* ATT */ #endif /* sco */ #include #include #ifdef DIRENT #include --- 101,107 ----- #endif /* not HPUX */ #ifndef VMS #include + #endif /* not VMS */ #include #ifdef DIRENT #ifdef VMS ************** *** 89,94 #include #include #ifdef DIRENT #include #endif #endif --- 104,113 ----- #endif /* not VMS */ #include #ifdef DIRENT + #ifdef VMS + #include + #include "dirent.h" + #else #include #endif /* VMS */ #endif /* DIRENT */ ************** *** 90,97 #include #ifdef DIRENT #include ! #endif ! #endif #ifdef NEEDSVARARGS #include --- 109,117 ----- #include "dirent.h" #else #include ! #endif /* VMS */ ! #endif /* DIRENT */ ! #endif /* NEEDSDIR */ #ifdef NEEDSVARARGS #include ************** *** 100,106 /* signal macros */ #ifdef SVR4 #define HOLD_SIG sighold(SIGALRM) /* block ALRM sig from occurring */ ! #define RELEASE_SIG sigrelse(SIGALRM) /* #define PAUSE_SIG sigpause(SIGALRM) /* sleep until ALRM signal */ #else #define HOLD_SIG sigblock(sigmask(SIGALRM)) --- 120,126 ----- /* signal macros */ #ifdef SVR4 #define HOLD_SIG sighold(SIGALRM) /* block ALRM sig from occurring */ ! #define RELEASE_SIG sigrelse(SIGALRM) /* */ #define PAUSE_SIG sigpause(SIGALRM) /* sleep until ALRM signal */ #else #define HOLD_SIG sigblock(sigmask(SIGALRM)) ************** *** 119,124 #undef PAUSE_SIG #define PAUSE_SIG /* */ #else #define UNCOMPRESS "/usr/ucb/uncompress" /* for uncompressing .Z files */ #endif --- 139,148 ----- #undef PAUSE_SIG #define PAUSE_SIG /* */ #else + #ifdef VMS + #define MAXPATHLEN 500 + #define UNCOMPRESS "decompress" /* for uncompressing .Z files */ + #endif /* VMS */ #define UNCOMPRESS "/usr/ucb/uncompress" /* for uncompressing .Z files */ #endif /* i386 */ ************** *** 120,126 #define PAUSE_SIG /* */ #else #define UNCOMPRESS "/usr/ucb/uncompress" /* for uncompressing .Z files */ ! #endif #define PROGNAME "xv" /* used in resource database */ --- 144,150 ----- #define UNCOMPRESS "decompress" /* for uncompressing .Z files */ #endif /* VMS */ #define UNCOMPRESS "/usr/ucb/uncompress" /* for uncompressing .Z files */ ! #endif /* i386 */ #define PROGNAME "xv" /* used in resource database */ ************** *** 298,305 #define RANGE(a,b,c) { if (ac) a=c; } /* PTINRECT returns '1' if x,y is in rect (inclusive) */ ! #define PTINRECT(x,y,rx,ry,rw,rh) \ ! ((x)>=(rx) && (y)>=(ry) && (x)<=(rx)+(rw) && (y)<=(ry)+(rh)) /* MONO returns total intensity of r,g,b components */ #define MONO(rd,gn,bl) (((rd)*11 + (gn)*16 + (bl)*5) >> 5) /*.33R+ .5G+ .17B*/ --- 322,328 ----- #define RANGE(a,b,c) { if (ac) a=c; } /* PTINRECT returns '1' if x,y is in rect (inclusive) */ ! #define PTINRECT(x,y,rx,ry,rw,rh) ((x)>=(rx) && (y)>=(ry) && (x)<=(rx)+(rw) && (y)<=(ry)+(rh)) /* MONO returns total intensity of r,g,b components */ #define MONO(rd,gn,bl) (((rd)*11 + (gn)*16 + (bl)*5) >> 5) /*.33R+ .5G+ .17B*/ ************** *** 350,355 WHERE unsigned long freecols[256]; /* list of pixel values to free */ WHERE int nfcols; /* number of colors to free */ WHERE unsigned long cols[256]; /* maps pic pixel values to X pixel vals */ WHERE int fc2pcol[256]; /* maps freecols into pic pixel values */ WHERE int numcols; /* # of desired colors in picture */ --- 373,381 ----- WHERE unsigned long freecols[256]; /* list of pixel values to free */ WHERE int nfcols; /* number of colors to free */ + #ifdef VMS + WHERE unsigned long colors[256]; /* maps pic pixel values to X pixel vals */ + #else WHERE unsigned long cols[256]; /* maps pic pixel values to X pixel vals */ #endif WHERE int fc2pcol[256]; /* maps freecols into pic pixel values */ ************** *** 351,356 WHERE unsigned long freecols[256]; /* list of pixel values to free */ WHERE int nfcols; /* number of colors to free */ WHERE unsigned long cols[256]; /* maps pic pixel values to X pixel vals */ WHERE int fc2pcol[256]; /* maps freecols into pic pixel values */ WHERE int numcols; /* # of desired colors in picture */ WHERE int ncols; /* max # of (different) colors to alloc */ --- 377,383 ----- WHERE unsigned long colors[256]; /* maps pic pixel values to X pixel vals */ #else WHERE unsigned long cols[256]; /* maps pic pixel values to X pixel vals */ + #endif WHERE int fc2pcol[256]; /* maps freecols into pic pixel values */ WHERE int numcols; /* # of desired colors in picture */ WHERE int ncols; /* max # of (different) colors to alloc */ ************** *** 370,376 noqcheck, /* true if we should NOT do QuickCheck */ rwcolor, /* true if we should use R/W color cells */ rwthistime, /* true if we DID use R/W color cells */ - brokeFreeCols, /* true if server has broken XFreeColors */ fish, /* turn on annoying fish */ fishrunning; /* true if fish are in operation */ --- 397,402 ----- noqcheck, /* true if we should NOT do QuickCheck */ rwcolor, /* true if we should use R/W color cells */ rwthistime, /* true if we DID use R/W color cells */ fish, /* turn on annoying fish */ fishrunning; /* true if fish are in operation */ ************** *** 428,433 void WRotate(void); void InvCropRect(void); void MakeRootPic(void); /*************************** XVMISC.C ***************************/ Window CreateWindow(char *, char *, unsigned int, unsigned int, --- 454,460 ----- void WRotate(void); void InvCropRect(void); void MakeRootPic(void); + void XvFreeColors(Display*, Colormap, unsigned long*, int, unsigned long, int); /*************************** XVMISC.C ***************************/ Window CreateWindow(char *, char *, unsigned int, unsigned int, ************** *** 558,563 int LoadXBM(char *, int); int WriteXBM(FILE *, byte *, int, int, char *); --- 585,592 ----- int LoadXBM(char *, int); int WriteXBM(FILE *, byte *, int, int, char *); + /**************************** XVJPEG.C ***************************/ + int LoadJFIF(char *, int); ************** *** 570,575 /****************************** XV.C ****************************/ void DrawWindow(), WCrop(), WUnCrop(), WResize(), WRotate(), InvCropRect(); void MakeRootPic(); /*************************** XVMISC.C ***************************/ Window CreateWindow(); --- 599,605 ----- /****************************** XV.C ****************************/ void DrawWindow(), WCrop(), WUnCrop(), WResize(), WRotate(), InvCropRect(); void MakeRootPic(); + void XvFreeColors(); /*************************** XVMISC.C ***************************/ Window CreateWindow(); ************** *** 632,636 /**************************** XVXBM.C ***************************/ int LoadXBM(), WriteXBM(); #endif --- 662,668 ----- /**************************** XVXBM.C ***************************/ int LoadXBM(), WriteXBM(); + /**************************** XVJPEG.C ***************************/ + int LoadJFIF(); #endif *** disk$vis:[xv.orig]xv24to8.c --- xv24to8.c ************** *** 73,79 static int Quick24to8(); static int QuickCheck(); ! static byte tbl1[256], /* tables used in F-S Dithering */ tbl3[256], /* contain i/16, 3i/16, 5i/16, 7i/16, */ tbl5[256], /* (i=0-255) respectively */ tbl7[256]; --- 73,79 ----- static int Quick24to8(); static int QuickCheck(); ! static int tbl1[256], /* tables used in F-S Dithering */ tbl3[256], /* contain i/16, 3i/16, 5i/16, 7i/16, */ tbl5[256], /* (i=-128..127) respectively */ tbl7[256]; ************** *** 75,81 static byte tbl1[256], /* tables used in F-S Dithering */ tbl3[256], /* contain i/16, 3i/16, 5i/16, 7i/16, */ ! tbl5[256], /* (i=0-255) respectively */ tbl7[256]; --- 75,81 ----- static int tbl1[256], /* tables used in F-S Dithering */ tbl3[256], /* contain i/16, 3i/16, 5i/16, 7i/16, */ ! tbl5[256], /* (i=-128..127) respectively */ tbl7[256]; ************** *** 508,516 byte *rp,*gp,*bp; /*******************************/ { ! *rp = ((ptr->rmin + ptr->rmax) << (COLOR_DEPTH - B_DEPTH)) / 2; ! *gp = ((ptr->gmin + ptr->gmax) << (COLOR_DEPTH - B_DEPTH)) / 2; ! *bp = ((ptr->bmin + ptr->bmax) << (COLOR_DEPTH - B_DEPTH)) / 2; } --- 508,517 ----- byte *rp,*gp,*bp; /*******************************/ { ! /* +1 ensures that color represents the middle of the box */ ! *rp = ((ptr->rmin + ptr->rmax + 1) << (COLOR_DEPTH - B_DEPTH)) / 2; ! *gp = ((ptr->gmin + ptr->gmax + 1) << (COLOR_DEPTH - B_DEPTH)) / 2; ! *bp = ((ptr->bmin + ptr->bmax + 1) << (COLOR_DEPTH - B_DEPTH)) / 2; } ************** *** 674,680 int *thisline, *nextline, *tmpptr; int r1, g1, b1, r2, g2, b2; int i, j, imax, jmax, oval; ! byte *inptr, *outptr, *tmpbptr; int lastline, lastpixel; imax = HIGH - 1; --- 675,681 ----- int *thisline, *nextline, *tmpptr; int r1, g1, b1, r2, g2, b2; int i, j, imax, jmax, oval; ! byte *inptr, *outptr; int lastline, lastpixel; imax = HIGH - 1; ************** *** 694,701 outptr = (byte *) pic; /* get first line of picture */ ! for (j=WIDE * 3, tmpptr=nextline, tmpbptr=inptr; j; j--) ! *tmpptr++ = (int) *tmpbptr++; for (i=0; i>3)&0x1c) | (b1>>6); if (j!=jmax) { /* adjust RIGHT pixel */ thisptr[0] += tbl7[rerr]; --- 855,863 ----- r1 = *thisptr++; g1 = *thisptr++; b1 = *thisptr++; RANGE(r1,0,255); RANGE(g1,0,255); RANGE(b1,0,255); ! /* choose actual pixel value */ ! val = ((r1&RMASK)>>RSHIFT) | ((g1&GMASK)>>GSHIFT) | ((b1&BMASK)>>BSHIFT); ! *pp = val; /* compute color errors */ r1 -= r[val]; ************** *** 843,848 rerr = r1 & 0x1f; gerr = g1 & 0x1f; berr = b1 & 0x3f; *pp = (r1&0xe0) | ((g1>>3)&0x1c) | (b1>>6); if (j!=jmax) { /* adjust RIGHT pixel */ thisptr[0] += tbl7[rerr]; thisptr[1] += tbl7[gerr]; --- 859,874 ----- val = ((r1&RMASK)>>RSHIFT) | ((g1&GMASK)>>GSHIFT) | ((b1&BMASK)>>BSHIFT); *pp = val; + /* compute color errors */ + r1 -= r[val]; + g1 -= g[val]; + b1 -= b[val]; + + /* Add fractions of errors to adjacent pixels */ + r1 += 128; /* make positive for table indexing */ + g1 += 128; + b1 += 128; + if (j!=jmax) { /* adjust RIGHT pixel */ thisptr[0] += tbl7[r1]; thisptr[1] += tbl7[g1]; ************** *** 844,852 *pp = (r1&0xe0) | ((g1>>3)&0x1c) | (b1>>6); if (j!=jmax) { /* adjust RIGHT pixel */ ! thisptr[0] += tbl7[rerr]; ! thisptr[1] += tbl7[gerr]; ! thisptr[2] += tbl7[berr]; } if (i!=imax) { /* do BOTTOM pixel */ --- 870,878 ----- b1 += 128; if (j!=jmax) { /* adjust RIGHT pixel */ ! thisptr[0] += tbl7[r1]; ! thisptr[1] += tbl7[g1]; ! thisptr[2] += tbl7[b1]; } if (i!=imax) { /* do BOTTOM pixel */ ************** *** 850,858 } if (i!=imax) { /* do BOTTOM pixel */ ! nextptr[0] += tbl5[rerr]; ! nextptr[1] += tbl5[gerr]; ! nextptr[2] += tbl5[berr]; if (j>0) { /* do BOTTOM LEFT pixel */ nextptr[-3] += tbl3[rerr]; --- 876,884 ----- } if (i!=imax) { /* do BOTTOM pixel */ ! nextptr[0] += tbl5[r1]; ! nextptr[1] += tbl5[g1]; ! nextptr[2] += tbl5[b1]; if (j>0) { /* do BOTTOM LEFT pixel */ nextptr[-3] += tbl3[r1]; ************** *** 855,863 nextptr[2] += tbl5[berr]; if (j>0) { /* do BOTTOM LEFT pixel */ ! nextptr[-3] += tbl3[rerr]; ! nextptr[-2] += tbl3[gerr]; ! nextptr[-1] += tbl3[berr]; } if (j!=jmax) { /* do BOTTOM RIGHT pixel */ --- 881,889 ----- nextptr[2] += tbl5[b1]; if (j>0) { /* do BOTTOM LEFT pixel */ ! nextptr[-3] += tbl3[r1]; ! nextptr[-2] += tbl3[g1]; ! nextptr[-1] += tbl3[b1]; } if (j!=jmax) { /* do BOTTOM RIGHT pixel */ ************** *** 861,869 } if (j!=jmax) { /* do BOTTOM RIGHT pixel */ ! nextptr[3] += tbl1[rerr]; ! nextptr[4] += tbl1[gerr]; ! nextptr[5] += tbl1[berr]; } nextptr += 3; } --- 887,895 ----- } if (j!=jmax) { /* do BOTTOM RIGHT pixel */ ! nextptr[3] += tbl1[r1]; ! nextptr[4] += tbl1[g1]; ! nextptr[5] += tbl1[b1]; } nextptr += 3; } ************** *** 880,890 /****************************/ { int i; ! for (i=0; i<256; i++) { /* initialize Floyd-Steinberg division tables */ ! tbl1[i] = i/16; ! tbl3[i] = (3*i)/16; ! tbl5[i] = (5*i)/16; ! tbl7[i] = (7*i)/16; } } --- 906,926 ----- /****************************/ { int i; ! ! /* initialize Floyd-Steinberg division tables */ ! /* make sure rounding is done correctly for negative values! */ ! ! for (i = -128; i < 0; i++) { ! tbl1[i+128] = -((8 -i )/16); ! tbl3[i+128] = -((8 -3*i)/16); ! tbl5[i+128] = -((8 -5*i)/16); ! tbl7[i+128] = -((8 -7*i)/16); ! } ! for (i = 0; i < 128; i++) { ! tbl1[i+128] = (i +8)/16; ! tbl3[i+128] = (3*i+8)/16; ! tbl5[i+128] = (5*i+8)/16; ! tbl7[i+128] = (7*i+8)/16; } } *** disk$vis:[xv.orig]xvdir.c --- xvdir.c ************** *** 336,342 numdirnames = 0; ! #ifdef SYSV getcwd(path, sizeof(path)); #else getwd(path); --- 336,342 ----- numdirnames = 0; ! #if (defined(SYSV) || defined(SVR4) || defined(VMS)) getcwd(path, sizeof(path)); #else getwd(path); ************** *** 385,391 /* figure out what type of file the beastie is */ dirnames[i][0] = C_REG; /* default to normal file, if lstat fails */ ! #if defined(i386) || defined (SYSV) if (stat(dirnames[i]+1, &st)==0) { #else if (lstat(dirnames[i]+1, &st)==0) { --- 385,391 ----- /* figure out what type of file the beastie is */ dirnames[i][0] = C_REG; /* default to normal file, if lstat fails */ ! #if defined(i386) || defined (SYSV) || defined (VMS) if (stat(dirnames[i]+1, &st)==0) { #else if (lstat(dirnames[i]+1, &st)==0) { ************** *** 425,431 RedrawDirW(0,0,DIRWIDE,DIRHIGH); } - /***************************************************/ static int dnamcmp(s1,s2) char **s1, **s2; --- 425,430 ----- RedrawDirW(0,0,DIRWIDE,DIRHIGH); } /***************************************************/ static int dnamcmp(s1,s2) char **s1, **s2; ************** *** 539,544 /* open file */ fp = fopen(filename, "w"); if (!fp) { SetISTR(ISTR_INFO,"Can't create '%s' - %s",filename,sys_errlist[errno]); Warning(); if (bwpic) free(bwpic); --- 538,546 ----- /* open file */ fp = fopen(filename, "w"); if (!fp) { + #ifdef VMS + SetISTR(ISTR_INFO,"Can't create '%s'",filename); + #else SetISTR(ISTR_INFO,"Can't create '%s' - %s",filename,sys_errlist[errno]); #endif Warning(); ************** *** 540,545 fp = fopen(filename, "w"); if (!fp) { SetISTR(ISTR_INFO,"Can't create '%s' - %s",filename,sys_errlist[errno]); Warning(); if (bwpic) free(bwpic); SetCursors(-1); --- 542,548 ----- SetISTR(ISTR_INFO,"Can't create '%s'",filename); #else SetISTR(ISTR_INFO,"Can't create '%s' - %s",filename,sys_errlist[errno]); + #endif Warning(); if (bwpic) free(bwpic); SetCursors(-1); *** disk$vis:[xv.orig]xvfish.c --- xvfish.c ************** *** 103,108 StopFish() /**************/ { struct itimerval it; #ifdef POSIX struct sigaction act; --- 103,109 ----- StopFish() /**************/ { + #ifndef VMS struct itimerval it; #endif #ifdef POSIX ************** *** 104,109 /**************/ { struct itimerval it; #ifdef POSIX struct sigaction act; #endif --- 105,111 ----- { #ifndef VMS struct itimerval it; + #endif #ifdef POSIX struct sigaction act; #endif ************** *** 121,126 #endif bzero(&it, sizeof(it)); it.it_interval.tv_usec = 0L; it.it_value.tv_usec = 0L; --- 123,129 ----- #endif + #ifndef VMS bzero(&it, sizeof(it)); it.it_interval.tv_usec = 0L; it.it_value.tv_usec = 0L; ************** *** 135,140 RELEASE_SIG; /* allow ALRM signals to happen (we don't get them) */ fishrunning = 0; #endif /* POSIX */ } --- 138,144 ----- RELEASE_SIG; /* allow ALRM signals to happen (we don't get them) */ fishrunning = 0; #endif /* POSIX */ + #endif /* VMS */ } ************** *** 177,182 static void setfishtimer() /*******/ { struct itimerval it; #ifdef POSIX struct sigaction act; --- 181,187 ----- static void setfishtimer() /*******/ { + #ifndef VMS struct itimerval it; #endif #ifdef POSIX ************** *** 178,183 /*******/ { struct itimerval it; #ifdef POSIX struct sigaction act; #endif --- 183,189 ----- { #ifndef VMS struct itimerval it; + #endif #ifdef POSIX struct sigaction act; #endif ************** *** 181,186 #ifdef POSIX struct sigaction act; #endif bzero(&it, sizeof(it)); it.it_value.tv_usec = DELAY; --- 187,193 ----- #ifdef POSIX struct sigaction act; #endif + #ifndef VMS bzero(&it, sizeof(it)); it.it_value.tv_usec = DELAY; ************** *** 193,198 RELEASE_SIG; /* enable ALRM signals */ setitimer(ITIMER_REAL, &it, (struct itimerval *)0); #endif /* POSIX */ } --- 200,206 ----- RELEASE_SIG; /* enable ALRM signals */ setitimer(ITIMER_REAL, &it, (struct itimerval *)0); #endif /* POSIX */ + #endif /* VMS */ } *** disk$vis:[xv.orig]xvgam.c --- xvgam.c ************** *** 620,640 LocalCmap = 0; } else { ! if (!brokeFreeCols) { ! for (i=0; iuse - a->use); - } - - /***********************************/ void SortColormap() { --- 207,212 ----- } CMAPENT; /***********************************/ void SortColormap() { ************** *** 216,223 void SortColormap() { byte *p; ! int i, j, k, mdist, entry, mn, d, hist[256], trans[256]; ! static CMAPENT c[256], c1[256], *cp, *cj, *ck; /* no point doing this if we're on a 1-bit display */ --- 211,218 ----- void SortColormap() { byte *p; ! int i, j, k, mdist, entry, d, hist[256], trans[256]; ! CMAPENT c[256], c1[256], *cp, *cj, *ck; /* no point doing this if we're on a 1-bit display */ ************** *** 243,248 cp = &c[numcols++]; cp->r = r[i]; cp->g = g[i]; cp->b = b[i]; cp->use = hist[i]; cp->oldindex = i; } } --- 238,244 ----- cp = &c[numcols++]; cp->r = r[i]; cp->g = g[i]; cp->b = b[i]; cp->use = hist[i]; cp->oldindex = i; + cp->mindist = 100000; } } ************** *** 256,273 c[entry].use = 0; /* and mark it dealt with */ ! /* sort rest of colormap, in order of decreasing 'distance' from already ! allocated elements. ! ! FURTHER MODIFICATION of algorithm. The algorithm's performance ! utterly goes to hell as numcols increases. (Probably on the order ! of O^3 performance). Since I don't see a clever way of rewriting ! the algorithm for O^2 performance (which'd be acceptable), I'm going ! to make a trade-off. I'll only run the algorithm for the first 32 colors ! (or so). It can do that Real Fast. Then I'll just stick the rest of ! the unsorted colors (if any), and tack them on the end, in order of ! amount of use. This should give similar picture quality, with ! much higher performance. */ for (i=1; i0) marked with the minimum distance to any of ************** *** 269,277 amount of use. This should give similar picture quality, with much higher performance. */ ! for (i=1; iuse) { /* this color has not been marked already */ mn = 10000; --- 256,269 ----- basis of distance from already allocated colors, and half on the basis of usage. (NB: 'taxicab' distance is used throughout this file.) ! To obtain O(n^2) performance, we keep each unselected color ! (in c[], with use>0) marked with the minimum distance to any of ! the selected colors (in c1[]). Each time we select a color, we ! can update the minimum distances in O(n) time. */ ! ! for (i=1; iuse) { /* can ignore already-selected colors */ d = abs(cj->r - ck->r) + abs(cj->g - ck->g) + abs(cj->b - ck->b); ************** *** 273,281 /* find the i'th most different color */ entry = -1; mdist = -1; for (j=0, cj=c; juse) { /* this color has not been marked already */ ! mn = 10000; ! for (k=0, ck=c1; kr - ck->r) + abs(cj->g - ck->g) + abs(cj->b - ck->b); if (mn>d) mn=d; } --- 265,271 ----- /* First, update distances to the just-selected color */ ck = &c1[i-1]; /* point to just-selected color */ for (j=0, cj=c; juse) { /* can ignore already-selected colors */ d = abs(cj->r - ck->r) + abs(cj->g - ck->g) + abs(cj->b - ck->b); if (cj->mindist > d) cj->mindist = d; } ************** *** 277,283 mn = 10000; for (k=0, ck=c1; kr - ck->r) + abs(cj->g - ck->g) + abs(cj->b - ck->b); ! if (mn>d) mn=d; } /* mn = minimum distance from c[j] to already used colors */ /* we want to select the unused color that has the greatest mn */ --- 267,273 ----- for (j=0, cj=c; juse) { /* can ignore already-selected colors */ d = abs(cj->r - ck->r) + abs(cj->g - ck->g) + abs(cj->b - ck->b); ! if (cj->mindist > d) cj->mindist = d; } } ************** *** 279,288 d = abs(cj->r - ck->r) + abs(cj->g - ck->g) + abs(cj->b - ck->b); if (mn>d) mn=d; } - /* mn = minimum distance from c[j] to already used colors */ - /* we want to select the unused color that has the greatest mn */ - if (mn > mdist) { mdist = mn; entry = j; } - } } /* c[entry] is the next color to put in the map. do so */ --- 269,274 ----- d = abs(cj->r - ck->r) + abs(cj->g - ck->g) + abs(cj->b - ck->b); if (cj->mindist > d) cj->mindist = d; } } if (i&1) { ************** *** 284,289 if (mn > mdist) { mdist = mn; entry = j; } } } /* c[entry] is the next color to put in the map. do so */ memcpy(&c1[i], &c[entry], sizeof(CMAPENT)); --- 270,295 ----- if (cj->mindist > d) cj->mindist = d; } } + + if (i&1) { + /* Now find the i'th most different color */ + /* we want to select the unused color that has the greatest mindist */ + entry = -1; mdist = -1; + for (j=0, cj=c; juse) { /* this color has not been marked already */ + if (cj->mindist > mdist) { mdist = cj->mindist; entry = j; } + } + } + } else { + /* Now find the i'th most different color */ + /* we want to select the unused color that has the greatest usage */ + entry = -1; mdist = -1; + for (j=0, cj=c; juse) { /* this color has not been marked already */ + if (cj->use > mdist) { mdist = cj->use; entry = j; } + } + } + } /* c[entry] is the next color to put in the map. do so */ memcpy(&c1[i], &c[entry], sizeof(CMAPENT)); ************** *** 290,300 c[entry].use = 0; } - /* tack rest of colors onto colormap in decreasing order of use */ - qsort((char *) c,numcols,sizeof(CMAPENT),CMAPcompare); - memcpy(&c1[i], c, (numcols - i) * sizeof(CMAPENT)); - - /* build translation table */ for (i=0; i0; i--,pp++,ip++) { if ((i&0x1ffff) == 0) WaitCursor(); *ip = (byte) cols[*pp]; } } --- 1188,1196 ----- else { for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) { if ((i&0x1ffff) == 0) WaitCursor(); + #ifdef VMS + *ip = (byte) colors[*pp]; + #else *ip = (byte) cols[*pp]; #endif } ************** *** 1132,1137 for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) { if ((i&0x1ffff) == 0) WaitCursor(); *ip = (byte) cols[*pp]; } } --- 1192,1198 ----- *ip = (byte) colors[*pp]; #else *ip = (byte) cols[*pp]; + #endif } } ************** *** 1199,1204 for (i=0, pp=epic, lip=imagedata; ibits_per_pixel == 8) { for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) { if ((i&0x1ffff) == 0) WaitCursor(); *ip = (byte) cols[*pp]; } } --- 1273,1281 ----- else if (theImage->bits_per_pixel == 8) { for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) { if ((i&0x1ffff) == 0) WaitCursor(); + #ifdef VMS + *ip = (byte) colors[*pp]; + #else *ip = (byte) cols[*pp]; #endif } ************** *** 1208,1213 for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) { if ((i&0x1ffff) == 0) WaitCursor(); *ip = (byte) cols[*pp]; } } else FatalError("This display's too bizarre. Can't create XImage."); --- 1277,1283 ----- *ip = (byte) colors[*pp]; #else *ip = (byte) cols[*pp]; + #endif } } else FatalError("This display's too bizarre. Can't create XImage."); ************** *** 1238,1243 else { for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) { if ((i&0x1ffff) == 0) WaitCursor(); *ip = (byte) cols[*pp]; } } --- 1308,1316 ----- else { for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) { if ((i&0x1ffff) == 0) WaitCursor(); + #ifdef VMS + *ip = (byte) colors[*pp]; + #else *ip = (byte) cols[*pp]; #endif } ************** *** 1239,1244 for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++,ip++) { if ((i&0x1ffff) == 0) WaitCursor(); *ip = (byte) cols[*pp]; } } --- 1312,1318 ----- *ip = (byte) colors[*pp]; #else *ip = (byte) cols[*pp]; + #endif } } ************** *** 1262,1267 for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++) { if ((i&0x1ffff) == 0) WaitCursor(); *ip++ = 0; *ip++ = (cols[*pp]>>16) & 0xff; *ip++ = (cols[*pp]>>8) & 0xff; *ip++ = cols[*pp] & 0xff; --- 1336,1346 ----- for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++) { if ((i&0x1ffff) == 0) WaitCursor(); *ip++ = 0; + #ifdef VMS + *ip++ = (colors[*pp]>>16) & 0xff; + *ip++ = (colors[*pp]>>8) & 0xff; + *ip++ = colors[*pp] & 0xff; + #else *ip++ = (cols[*pp]>>16) & 0xff; *ip++ = (cols[*pp]>>8) & 0xff; *ip++ = cols[*pp] & 0xff; ************** *** 1265,1270 *ip++ = (cols[*pp]>>16) & 0xff; *ip++ = (cols[*pp]>>8) & 0xff; *ip++ = cols[*pp] & 0xff; } else for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++) { --- 1344,1350 ----- *ip++ = (cols[*pp]>>16) & 0xff; *ip++ = (cols[*pp]>>8) & 0xff; *ip++ = cols[*pp] & 0xff; + #endif } else for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++) { ************** *** 1269,1274 else for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++) { if ((i&0x1ffff) == 0) WaitCursor(); *ip++ = cols[*pp] & 0xff; *ip++ = (cols[*pp]>>8) & 0xff; *ip++ = (cols[*pp]>>16) & 0xff; --- 1349,1359 ----- else for (i=eWIDE*eHIGH, pp=epic, ip=imagedata; i>0; i--,pp++) { if ((i&0x1ffff) == 0) WaitCursor(); + #ifdef VMS + *ip++ = colors[*pp] & 0xff; + *ip++ = (colors[*pp]>>8) & 0xff; + *ip++ = (colors[*pp]>>16) & 0xff; + #else *ip++ = cols[*pp] & 0xff; *ip++ = (cols[*pp]>>8) & 0xff; *ip++ = (cols[*pp]>>16) & 0xff; ************** *** 1272,1277 *ip++ = cols[*pp] & 0xff; *ip++ = (cols[*pp]>>8) & 0xff; *ip++ = (cols[*pp]>>16) & 0xff; *ip++ = 0; } } --- 1357,1363 ----- *ip++ = cols[*pp] & 0xff; *ip++ = (cols[*pp]>>8) & 0xff; *ip++ = (cols[*pp]>>16) & 0xff; + #endif *ip++ = 0; } } ************** *** 1571,1576 /*******/ { long usec; struct itimerval it; if (!n) return; --- 1657,1663 ----- /*******/ { long usec; + #ifndef VMS struct itimerval it; #endif ************** *** 1572,1577 { long usec; struct itimerval it; if (!n) return; if (fishrunning) { PAUSE_SIG; return; } --- 1659,1665 ----- long usec; #ifndef VMS struct itimerval it; + #endif if (!n) return; if (fishrunning) { PAUSE_SIG; return; } ************** *** 1591,1596 return; #endif usec = (long) n * 1000; memset(&it, 0, sizeof(it)); --- 1679,1685 ----- return; #endif + #ifndef VMS usec = (long) n * 1000; memset(&it, 0, sizeof(it)); ************** *** 1611,1616 RELEASE_SIG; /* turn ALRM blocking off */ signal(SIGALRM,SIG_DFL); } --- 1700,1704 ----- RELEASE_SIG; /* turn ALRM blocking off */ signal(SIGALRM,SIG_DFL); + #endif /* VMS */ } ************** *** 1612,1620 RELEASE_SIG; /* turn ALRM blocking off */ signal(SIGALRM,SIG_DFL); } - - - - - - --- 1702,1704 ----- signal(SIGALRM,SIG_DFL); #endif /* VMS */ }