IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15906


Ignore:
Timestamp:
Dec 22, 2007, 8:02:23 AM (18 years ago)
Author:
eugene
Message:

more flexible pixel allocation, preparing for 3d colors

Location:
branches/eam_branch_20071222/Ohana/src/kapa2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20071222/Ohana/src/kapa2/include/structures.h

    r14590 r15906  
    1414  int            x,  y;
    1515  unsigned int   dx, dy;
    16   XColor         cmap[256];
     16  XColor         cmap[1024];
    1717  Colormap       colormap;
    1818  unsigned long  fore;
    1919  unsigned long  back;
    2020  unsigned long  *color;
    21   unsigned long  pixels[256];
     21  unsigned long  pixels[1024];
    2222  unsigned long  overlay_color[NOVERLAYS];
    2323  int Npixels;
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/CheckVisual.c

    r13479 r15906  
    177177
    178178  if (!dyn) {
    179     graphic[0].Npixels = 256;
     179    graphic[0].Npixels = 1024;
    180180    // fprintf (stderr, "can't use dynamic colors, color scrollbar inactive\n");
    181181    // fprintf (stderr, " this can be avoided by using a dynamic visual class\n");
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/InterpretKeys.c

    r14590 r15906  
    132132      break;
    133133
     134    case XK_KP_Add:
     135      image[0].zero += 0.1*image[0].range;
     136      Reorient (graphic, image, image[0].X, image[0].Y, 0);
     137      break;
     138    case XK_KP_Subtract:
     139      image[0].zero -= 0.1*image[0].range;
     140      Reorient (graphic, image, image[0].X, image[0].Y, 0);
     141      break;
     142
    134143    case XK_Tab:
    135144      image[0].MovePointer = image[0].MovePointer ^ TRUE;
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap32.c

    r13479 r15906  
    66
    77// XXX inline this if needed
     8# define PixelLookup(VALUE) (int)(MIN (MAX (slope * VALUE - start, 0), MaxValue))
     9
     10# if  (0)
    811static int PixelLookup(float value) {
    912  int out;
     
    1114  return (out);
    1215}
     16# endif
    1317
    1418void Remap32 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) {
     
    2226  unsigned int *out_pix, *out_pix2;
    2327  float *imdata, *in_pix, *in_pix2;
    24   unsigned long pixel[256], pixvalue;
     28  unsigned long *pixel, pixvalue;
    2529  unsigned long back;
    2630
     31  ALLOCATE (pixel, unsigned long, graphic[0].Npixels);
     32
    2733  // local array for pixel values
    28   for (i = 0; i < 256; i++) {
     34  for (i = 0; i < graphic[0].Npixels; i++) {
    2935    pixel[i] = graphic[0].cmap[i].pixel;
    3036  }
     
    154160  image[0].picture.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0,
    155161                                        image[0].picture.data, image[0].picture.dx, image[0].picture.dy, 32, 0);
     162
     163  free (pixel);
    156164}
    157165
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/SetColormap.c

    r13320 r15906  
    44     first to get better control over the smooth greyscales ***/
    55
     6/** red,green,blue are values in range 0x0000 to 0xffff **/
     7
    68int SetColormap (char *name) {
    79
    810  int i;
     11  float scale;
    912  Graphic *graphic;
    1013
     
    1316  /* greyscale */
    1417  if ((!strcmp (name, "grayscale")) || (!strcmp (name, "greyscale"))) {
     18
     19    scale = 0xffff / graphic[0].Npixels;
     20
    1521    for (i = 0; i < graphic[0].Npixels; i++) { 
    16       graphic[0].cmap[i].red = 256*(255 - 255*i/graphic[0].Npixels);
    17       graphic[0].cmap[i].green = 256*(255 - 255*i/graphic[0].Npixels);
    18       graphic[0].cmap[i].blue = 256*(255 - 255*i/graphic[0].Npixels);
     22      graphic[0].cmap[i].red   = 0xffff - i*scale;
     23      graphic[0].cmap[i].green = 0xffff - i*scale;
     24      graphic[0].cmap[i].blue  = 0xffff - i*scale;
     25      graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
     26    }
     27    goto store_colors;
     28  }
     29  /* -grayscale */
     30  if ((!strcmp (name, "-grayscale")) || (!strcmp (name, "-greyscale"))) {
     31    for (i = 0; i < graphic[0].Npixels; i++) { 
     32      graphic[0].cmap[i].red = 256*(255*i/graphic[0].Npixels);
     33      graphic[0].cmap[i].green = 256*(255*i/graphic[0].Npixels);
     34      graphic[0].cmap[i].blue = 256*(255*i/graphic[0].Npixels);
    1935      graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
    2036    }
     
    4561      graphic[0].cmap[i].green = 256*255;
    4662      graphic[0].cmap[i].blue = MIN (256*255, 256*255*2*(i/(1.0*graphic[0].Npixels) - 0.50));
    47       graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
    48     }
    49     goto store_colors;
    50   }
    51   /* -grayscale */
    52   if ((!strcmp (name, "-grayscale")) || (!strcmp (name, "-greyscale"))) {
    53     for (i = 0; i < graphic[0].Npixels; i++) { 
    54       graphic[0].cmap[i].red = 256*(255*i/graphic[0].Npixels);
    55       graphic[0].cmap[i].green = 256*(255*i/graphic[0].Npixels);
    56       graphic[0].cmap[i].blue = 256*(255*i/graphic[0].Npixels);
    5763      graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
    5864    }
Note: See TracChangeset for help on using the changeset viewer.