ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/x11image.c
(Generate patch)

Comparing ray/src/px/x11image.c (file contents):
Revision 2.6 by greg, Wed May 27 14:28:50 1992 UTC vs.
Revision 2.7 by greg, Thu May 28 09:43:09 1992 UTC

# Line 135 | Line 135 | char  *argv[];
135                                  maxcolors = 2;
136                                  break;
137                          case 'd':
138 <                                if (argv[i][2] == 'i') {
138 >                                if (argv[i][2] == 'i')
139                                          dispname = argv[++i];
140 <                                        break;
141 <                                }
142 <                                dither = !dither;
140 >                                else
141 >                                        dither = !dither;
142                                  break;
143                          case 'f':
144                                  fast = !fast;
# Line 150 | Line 149 | char  *argv[];
149                                  scale = atoi(argv[++i]);
150                                  break;
151                          case 'g':
152 <                                if (!strcmp(argv[i], "-geometry"))
152 >                                if (argv[i][2] == 'e')
153                                          geometry = argv[++i];
154                                  else
155                                          gamcor = atof(argv[++i]);
# Line 191 | Line 190 | char  *argv[];
190                  getevent();             /* main loop */
191   userr:
192          fprintf(stderr,
193 <        "Usage: %s [-geometry spec][-b][-m][-d][-f][-c ncolors][-e +/-stops] file\n",
193 >        "Usage: %s [-display disp][-geometry spec][-b][-m][-d][-f][-c ncolors][-e +/-stops] file\n",
194                          progname);
195          quit(1);
196   }
# Line 362 | Line 361 | register XVisualInfo   *v1, *v2;
361  
362   getbestvis()                    /* get the best visual for this screen */
363   {
364 + #ifdef DEBUG
365   static char  vistype[][12] = {
366                  "StaticGray",
367                  "GrayScale",
# Line 370 | Line 370 | static char  vistype[][12] = {
370                  "TrueColor",
371                  "DirectColor"
372   };
373 + #endif
374          static int      rankings[3][6] = {
375                  {TrueColor,DirectColor,PseudoColor,GrayScale,StaticGray,-1},
376 <                {PseudoColor,GrayScale,-1},
377 <                {PseudoColor,GrayScale,-1}
376 >                {PseudoColor,GrayScale,StaticGray,-1},
377 >                {PseudoColor,GrayScale,StaticGray,-1}
378          };
379          XVisualInfo     *xvi;
380          int     vismatched;
# Line 393 | Line 394 | static char  vistype[][12] = {
394          xvi = XGetVisualInfo(thedisplay,VisualScreenMask,&ourvis,&vismatched);
395          if (xvi == NULL)
396                  quiterr("no visuals for this screen!");
397 < for (i = 0; i < vismatched; i++)
398 < fprintf(stderr, "Type %s, depth %d\n", vistype[xvi[i].class], xvi[i].depth);
397 > #ifdef DEBUG
398 >        fprintf(stderr, "Supported visuals:\n");
399 >        for (i = 0; i < vismatched; i++)
400 >                fprintf(stderr, "\ttype %s, depth %d\n",
401 >                                vistype[xvi[i].class], xvi[i].depth);
402 > #endif
403          for (i = 0, j = 1; j < vismatched; j++)
404                  if (viscmp(&xvi[i],&xvi[j]) > 0)
405                          i = j;
# Line 407 | Line 412 | fprintf(stderr, "Type %s, depth %d\n", vistype[xvi[i].
412                  quiterr("inadequate visuals on this screen");
413                                          /* OK, we'll use it */
414          copystruct(&ourvis, &xvi[i]);
415 < fprintf(stderr, "Selected visual type %s, depth %d\n", vistype[ourvis.class],
416 < ourvis.depth);
415 > #ifdef DEBUG
416 >        fprintf(stderr, "Selected visual type %s, depth %d\n",
417 >                        vistype[ourvis.class], ourvis.depth);
418 > #endif
419          if (ourvis.class == GrayScale || ourvis.class == StaticGray)
420                  greyscale = 1;
421 <        if (1<<ourvis.depth < maxcolors)
422 <                maxcolors = 1<<ourvis.depth;
421 >        if (ourvis.depth <= 8 && ourvis.colormap_size < maxcolors)
422 >                maxcolors = ourvis.colormap_size;
423          if (maxcolors > 4)
424                  maxcolors -= 2;
425          XFree((char *)xvi);
# Line 450 | Line 457 | getras()                               /* get raster file */
457                                  xmax, ymax, 8);
458                  if (ourras == NULL)
459                          goto fail;
460 <                if (greyscale)
461 <                        biq(dither,maxcolors,1,ourmap);
462 <                else
463 <                        ciq(dither,maxcolors,1,ourmap);
464 <                if (init_rcolors(ourras, ourmap[0], ourmap[1], ourmap[2]) == 0)
465 <                        goto fail;
460 >                if (ourvis.class == StaticGray)
461 >                        getgrey();
462 >                else {
463 >                        if (greyscale)
464 >                                biq(dither,maxcolors,1,ourmap);
465 >                        else
466 >                                ciq(dither,maxcolors,1,ourmap);
467 >                        if (init_rcolors(ourras, ourmap[0],
468 >                                        ourmap[1], ourmap[2]) == 0)
469 >                                goto fail;
470 >                }
471          }
472 <        return;
472 >                return;
473   fail:
474          quiterr("could not create raster image");
475   }
# Line 488 | Line 500 | getevent()                             /* process the next event */
500                          make_rpixmap(ourras, wind);
501                  break;
502          case UnmapNotify:
503 <                unmap_rcolors(ourras);
503 >                if (!fast)
504 >                        unmap_rcolors(ourras);
505                  break;
506          case Expose:
507                  redraw(e.e.x, e.e.y, e.e.width, e.e.height);
# Line 844 | Line 857 | getfull()                      /* get full (24-bit) data */
857   }
858  
859  
860 + getgrey()                       /* get greyscale data */
861 + {
862 +        int     y;
863 +        register unsigned char  *dp;
864 +        register int    x;
865 +                                        /* set gamma correction */
866 +        setcolrgam(gamcor);
867 +                                        /* read and convert file */
868 +        dp = ourdata;
869 +        for (y = 0; y < ymax; y++) {
870 +                if (getscan(y) < 0)
871 +                        quiterr("seek error in getfull");
872 +                if (scale)
873 +                        shiftcolrs(scanline, xmax, scale);
874 +                colrs_gambs(scanline, xmax);
875 +                add2icon(y, scanline);
876 +                if (ourvis.colormap_size < 256)
877 +                        for (x = 0; x < xmax; x++)
878 +                                *dp++ = ((long)normbright(scanline[x]) *
879 +                                        ourvis.colormap_size + 128) >> 8;
880 +                else
881 +                        for (x = 0; x < xmax; x++)
882 +                                *dp++ = normbright(scanline[x]);
883 +        }
884 + }
885 +
886 +
887   scale_rcolors(xr, sf)                   /* scale color map */
888   register XRASTER        *xr;
889   double  sf;
# Line 935 | Line 975 | colormap  map;
975   picwritecm(map)                 /* handled elsewhere */
976   colormap  map;
977   {
978 < #ifdef DEBUG
978 > #if 0
979          register int i;
980  
981          for (i = 0; i < 256; i++)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines