IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 6, 2008, 1:41:58 PM (19 years ago)
Author:
eugene
Message:

updates from eam_branch_20071222 : new 3D color map and multiple channels

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kapa2/src/CreateZoom32.c

    r13479 r16011  
    11# include "Ximage.h"
    22# define FRAC(a) ((a) - (int)(a))
    3 
    4 static float slope = 1.0;
    5 static float start = 0.0;
    6 static int MaxValue = 255;
    7 
    8 // XXX inline this if needed
    9 static int PixelLookup(float value) {
    10   int out;
    11   out = MIN (MAX (slope * value - start, 0), MaxValue);
    12   return (out);
    13 }
    143
    154void CreateZoom32 (KapaImageWidget *image, Graphic *graphic, double x, double y) {
     
    2211  int expand_in, expand_out;
    2312  unsigned int *out_pix, *out_pix2;
    24   float *imdata, *in_pix, *in_pix2;
    25   unsigned long pixel[256], pixvalue;
     13  unsigned short *in_pix, *in_pix2;
     14  unsigned long *pixel, pixvalue;
    2615  unsigned long back;
    2716
    28   if (image[0].matrix.size == 0) {  /* create a test pattern */
     17  if (image[0].image[0].matrix.size == 0) {  /* create a test pattern */
    2918    REALLOCATE (image[0].zoom.data, char, 4*image[0].zoom.dx*image[0].zoom.dy);
    3019    image[0].zoom.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0,
     
    3322  }
    3423
    35   for (i = 0; i < 256; i++) { /* set up pixel array */
     24  ALLOCATE (pixel, unsigned long, graphic[0].Npixels);
     25
     26  // local array for pixel values
     27  for (i = 0; i < graphic[0].Npixels; i++) {
    3628    pixel[i] = graphic[0].cmap[i].pixel;
    3729  }
    3830  back = graphic[0].back;
    39 
    40   // define the color transform parameters
    41   MaxValue = graphic[0].Npixels - 1;
    42   if (image[0].range != 0.0) {
    43     slope = graphic[0].Npixels / image[0].range;
    44     start = graphic[0].Npixels * image[0].zero / image[0].range;
    45   } else {
    46     slope = 1.0;
    47     start = image[0].zero;
    48   }
    4931
    5032  zoomscale = MAX (5, image[0].expand + 5);
     
    5537  dx = image[0].zoom.dx;
    5638  dy = image[0].zoom.dy;
    57   DX = image[0].matrix.Naxis[0];
    58   DY = image[0].matrix.Naxis[1];
     39  DX = image[0].image[0].matrix.Naxis[0];
     40  DY = image[0].image[0].matrix.Naxis[1];
     41 
     42  /* Rx,Ry are the screen coordinates of the first image pixel */
    5943  Rx = x - expand*(int)(0.5*(dx + 1)) + 1;
    6044  Ry = y - expand*(int)(0.5*(dy + 1)) + 1;
     
    6448  i_end   = MAX (MIN ((DX-Rx) / expand, dx - expand_out + 1), 0);
    6549  j_end   = MAX (MIN ((DY-Ry) / expand, dy - expand_out + 1), 0);
     50
    6651  dropback = expand_out - (i_end - i_start) % expand_out;
    6752  if ((i_end - i_start) % expand_out == 0) dropback = 0;
    6853
    6954  out_pix = (unsigned int *) image[0].zoom.data;
    70   imdata  = (float *) image[0].matrix.buffer;
    71   in_pix  = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)];
     55  in_pix  = &image[0].pixmap[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)];
    7256
    7357  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
     
    7862    return;
    7963  }
    80   
     64 
    8165
    8266  /**** fill in bottom area ****/
    8367  for (j = 0; j < dx*j_start; j++, out_pix++) {
    84     out_pix[0] = back;
     68    *out_pix = back;
    8569  }
    8670
     
    8872
    8973    /**** fill in area to the left of the picture ****/
    90     for (jj = 0; jj < expand_out; jj++) {
     74    for (jj = 0; (i_start > 0) && (jj < expand_out); jj++) {
    9175      out_pix2 = out_pix + jj*dx;
    9276      for (i = 0; i < i_start; i++, out_pix2++) {
    93         out_pix[0] = back;
     77        *out_pix2 = back;
    9478      }
    9579    }
     
    10084    if (expand_out == 1) {
    10185      for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) {
    102         pixelN = PixelLookup(*in_pix2);
    103         out_pix[0] = pixel[pixelN];
     86        *out_pix = pixel[*in_pix2];
    10487      }
    105     }
    106     else {
     88    } else {
    10789      for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) {
    108         pixelN   = PixelLookup(*in_pix2);
    109         pixvalue = pixel[pixelN];
     90        pixvalue = pixel[*in_pix2];
    11091        out_pix2 = out_pix;
    11192        for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) {
    11293          for (ii = 0; ii < expand_out; ii++, out_pix2++) {
    113             out_pix2[0] = pixvalue;
     94            *out_pix2 = pixvalue;
    11495          }
    11596        }
     
    11798    }
    11899    out_pix -= dropback;
    119 
    120100   
    121101    /**** fill in area to the right of the picture ****/
     
    123103      out_pix2 = out_pix + jj*dx;
    124104      for (i = i_end; i < dx; i++, out_pix2++) {
    125         out_pix2[0] = back;
     105        *out_pix2 = back;
    126106      }
    127107    }
     
    134114  /**** fill in top area ****/
    135115  for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned int *)image[0].zoom.data < dx*dy); j++, out_pix++) {
    136     out_pix[0] = back;
     116    *out_pix = back;
    137117  }
    138118
    139   out_pix = (unsigned int *)image[0].zoom.data;
    140119  image[0].zoom.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0,
    141120                                        image[0].zoom.data, image[0].zoom.dx, image[0].zoom.dy, 32, 0);
    142121 
     122  free (pixel);
    143123}
Note: See TracChangeset for help on using the changeset viewer.